This project has moved and is read-only. For the latest updates, please go here.

Resample doesn't seem to work as expected

Nov 22, 2014 at 12:36 AM
Looking at the imagemagick documentation, it looks like resample should resample an image to the target double value for Pixels Per Inch or Pixels Per Cm.

In Magick.Net however, it seems to take a target width and height as integers, and it does not update the image's ResolutionX or ResolutionY properties after the resample.

MagickImage.Resample(targetWidth, targetHeight);

Also confusing is that in the MagickImageInfo class, width and height are referred to as such, and ResolutionX and ResolutionY seem to refer to the DPI. However the Resample method has parameters ResolutionX and ResolutionY, which now seem to be integers referring to the target width and height rather than doubles referring to the target DPI.

Am I going about this wrong? I would have expected the Resample method to provide double parameters for the dpi or dpcm. Or if it is going to work with a provided width and height, I would expect it to recalculate the image's ResolutionX and ResolutionY properties.

Basically I'm trying to resample a 72DPI image to 200DPI. It's adding more pixels, but not updating the Density. Any input is appreciated!
Dec 9, 2014 at 5:02 PM
The Resample method should change the DPI. If you want to change it from 72 to 200 you should call it with 200,200. It does not use doubles because Magick++ also not do that. This seems like something I will have to fix in ImageMagick and Magick.NET because the density is a double instead of an integer in MagickCore. I will create a work item for this and work on this next week when I am back home.
Dec 9, 2014 at 5:03 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Dec 9, 2014 at 5:59 PM
Thanks Dirk, I'll try it again, but when I was doing MagickImage.Resample(200, 200) previously, the image's ResolutionX and ResolutionY where not updating.
Dec 17, 2014 at 3:47 PM
Edited Dec 17, 2014 at 3:47 PM
The Resample(200,200) method incorrectly called the Resize method with the geometry argument instead of the Resample method. This bug will be fixed in the next release that will also use a PointD instead of a MagickGeometry for the Resample method.
Dec 17, 2014 at 5:35 PM
Wonderful! That's the behavior I was seeing as well (forgot to update the topic after re-testing).

Looking forward to the next build! Thanks again!