ImageMagick, PDF, MediaBox and CropBox

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
jimc99999
Posts: 21
Joined: 2009-01-29T08:44:41-07:00

Re: ImageMagick, PDF, MediaBox and CropBox

Post by jimc99999 »

I haven't tested yet with 6.5.0-9, however, any anyone at ImageMagick tell me whether they are planning on addressing these issues at all? If not, I can create my own hack to set these values properly.

Thanks,

Jim
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick, PDF, MediaBox and CropBox

Post by magick »

Post your patch to coders/pdf.c here and we will apply it to the Subversion trunk. Thanks.
jimc99999
Posts: 21
Joined: 2009-01-29T08:44:41-07:00

Re: ImageMagick, PDF, MediaBox and CropBox

Post by jimc99999 »

I had a look at coders/pdf.c, and it appears the calculation for MediaBox and CropBox are correct. However, the values are still not what they should be. That means the values used in the calculation must not be correct.

% convert -version
Version: ImageMagick 6.5.1-0 2009-04-03 Q8 http://www.imagemagick.org


% identify -verbose test.jpg
Image: test.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 5000x4000+0+0
Resolution: 125x125
Print size: 40x32
Units: PixelsPerInch


% convert test.jpg test.pdf


% identify -verbose test.pdf
Image: test.pdf
Format: PDF (Portable Document Format)
Class: DirectClass
Geometry: 5000x4000+0+0
Resolution: 72x72
Print size: 69.4444x55.5556


in the pdf, we have:

/MediaBox [0 0 5000 4000]
/CropBox [0 0 5000 4000]


According to the code in coders/pdf.c, these should be:

/MediaBox [0 0 2880 2304]
/CropBox [0 0 2880 2304]


which would cause identify to output:

Geometry: 2880x2304+0+0
Print size: 40x32
Resolution: 72x72


This would seem to indicate that in coders/pdf.c:1241, either media_info or resolution has incorrect values. However, debugging those is a bit more than I can do at the moment.

I can provide the test.jpg used to convert to pdf if desired.

Jim
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick, PDF, MediaBox and CropBox

Post by magick »

We can reproduce the problem you posted and have a fix. Look for it in ImageMagick-6.5.1-1 Beta by sometime tomorrow. Thanks.
Post Reply