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 » 2014-07-29T08:13:58-07:00

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: 1563
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Resolution units

Post by dlemstra » 2014-07-29T09:51:23-07:00

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 » 2014-08-08T12:55:29-07:00

My OS is Win 7. ImageMagick Version 6.8.9

User avatar
dlemstra
Posts: 1563
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Resolution units

Post by dlemstra » 2014-08-08T14:19:13-07:00

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 » 2014-08-11T05:02:47-07:00

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 » 2014-08-29T06:27:45-07:00

Anyone had this problem besides me?

User avatar
fmw42
Posts: 25272
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resolution units

Post by fmw42 » 2014-08-29T09:42:06-07:00

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 » 2014-09-19T10:45:35-07:00

@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: 11926
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Resolution units

Post by snibgo » 2014-09-19T11:06:01-07:00

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