Page 1 of 1
Resolution units
Posted: 2014-07-29T08:13:58-07:00
by albertisi
I have an image that i save with resolution and resolution unit like this:
Code: Select all
someImage.density(Geometry(resolution, resolution));
someImage.resolutionUnits(MagickCore::ResolutionType::PixelsPerCentimeterResolution);
someImage.write(imagePath);
Once i read the same image right after, my resolution units are set to unknown (0), why is that? I think that is the bug in magick++.
Read code:
Code: Select all
Image someImage2;
someImage2.read(imagePath);
int resUnit2 = someImage2.resolutionUnits();
I am saving an image in PNG format. Please let me know if you need more information.
Re: Resolution units
Posted: 2014-07-29T09:51:23-07:00
by dlemstra
What is your OS and version of ImageMagick?
Re: Resolution units
Posted: 2014-08-08T12:55:29-07:00
by albertisi
My OS is Win 7. ImageMagick Version 6.8.9
Re: Resolution units
Posted: 2014-08-08T14:19:13-07:00
by dlemstra
What is the format of the image you are reading and writing?
Re: Resolution units
Posted: 2014-08-11T05:02:47-07:00
by albertisi
I am reading and writing PNG format image.
-Albert
Re: Resolution units
Posted: 2014-08-29T06:27:45-07:00
by albertisi
Anyone had this problem besides me?
Re: Resolution units
Posted: 2014-08-29T09:42:06-07:00
by fmw42
If the input image has no resolution, it will have unknown units. So you must specify both -density and -units.
see
http://www.imagemagick.org/script/comma ... hp#density
http://www.imagemagick.org/script/comma ... .php#units
PNG only supports pixelspercentimeter, but if you specify pixelsperinch, IM will convert that for you appropriately.
Re: Resolution units
Posted: 2014-09-19T10:45:35-07:00
by albertisi
@fmw42 i am setting density, and units, as in my original post.
I debugged image magic, and the problem is during the retrieval of resolutionUnits from the image.
After i read the image, i call to return resolution units In Image.cpp this code gets executed
Code: Select all
Magick::ResolutionType Magick::Image::resolutionUnits(void) const
{
return(constOptions()->resolutionUnits());
}
Unfortunately constOptions() are not set, or updated during the read, so it contains default values for all attributes.
This code should be updated to this:
Code: Select all
Magick::ResolutionType Magick::Image::resolutionUnits(void) const
{
return(constImage()->units());
}
Image attributes contains all the attributes setup after the read, constOptions doesnt.
Not sure how to proceed further...
Re: Resolution units
Posted: 2014-09-19T11:06:01-07:00
by snibgo
alberisi wrote:This code should be updated to this: ...
Are you saying IM has a bug, and this is your suggested correction? If so, then post to the bugs forum
viewforum.php?f=3