Unable to save images with DPI changes
trinhpapa opened this issue · comments
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp
- I have verified if the problem exist in both
DEBUG
andRELEASE
mode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp version
3.0.2
Other ImageSharp packages and versions
No
Environment (Operating system, version and so on)
Windows 11 and Linux
.NET Framework version
.NET 6
Description
I uploaded the image from the path and saved the image as Jpeg, but it automatic changed the DPI from 300 to 72. I tried changing the DPI to 32 but it still saved the image with 72 DPI default. It doesn't seem to work.
Steps to Reproduce
using Image image = Image.Load(imagePath);
var metaData = image.Metadata;
var currentDPI = image.Metadata.HorizontalResolution;
if (currentDPI < 300)
{
image.Metadata.VerticalResolution = 300;
image.Metadata.HorizontalResolution = 300;
}
image.SaveAsJpeg("test.jpg", new JpegEncoder { Quality = 100 });
Images
I don't actually understand your issue.
You talk about changing the DPI to values other than 300 but your code sample changes the DPI to 300?
I looked at the properties of the second image you uploaded and that also say that the DPI is 300?
Yes, that's the example image I'm using for testing. When running that image and saving it to test.jpg, it is only 72dpi
OK.
Please try to supply all the relevant information in one go, otherwise it's just noise.