Resolution units

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
albertisi
Posts: 15
Joined: 2014-07-28T12:17:08-07:00
Authentication code: 6789

Resolution units

Post 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.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Resolution units

Post by dlemstra »

What is your OS and version of ImageMagick?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
albertisi
Posts: 15
Joined: 2014-07-28T12:17:08-07:00
Authentication code: 6789

Re: Resolution units

Post by albertisi »

My OS is Win 7. ImageMagick Version 6.8.9
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Resolution units

Post by dlemstra »

What is the format of the image you are reading and writing?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
albertisi
Posts: 15
Joined: 2014-07-28T12:17:08-07:00
Authentication code: 6789

Re: Resolution units

Post by albertisi »

I am reading and writing PNG format image.

-Albert
albertisi
Posts: 15
Joined: 2014-07-28T12:17:08-07:00
Authentication code: 6789

Re: Resolution units

Post by albertisi »

Anyone had this problem besides me?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resolution units

Post 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.
albertisi
Posts: 15
Joined: 2014-07-28T12:17:08-07:00
Authentication code: 6789

Re: Resolution units

Post 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...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Resolution units

Post 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
snibgo's IM pages: im.snibgo.com
Post Reply