convert from a picture to pdf doesn't keep the original size

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Sworddragon
Posts: 7
Joined: 2012-04-11T11:57:55-07:00
Authentication code: 8675308

convert from a picture to pdf doesn't keep the original size

Post by Sworddragon »

I'm using ImageMagick 6.6.9.7 (from the Ubuntu repository) and have already made a bug on Launchpad about this: https://bugs.launchpad.net/ubuntu/+sour ... bug/897009
I'm using Ubuntu 12.04 dev with imagemagick 8:6.6.9.7-5ubuntu1. I have converted a picture to a pdf but it was on 100% zoom in evince upscaled. But I can't say if convert is upscaling the picture on the conversion or if evince (I'm using evince 3.2.1-1ubuntu1) is upscaling the picture.

Steps to reproduce:

1. Create a white picture with a dimension of 100x100 pixel and save it as test.png.
2. Convert the picture with "convert test.png test.pdf".
3. Open test.pdf with evince and set the zoom level to 100%.
4. Make a screenshot of evince and check the dimensions of the white picture (for example with GIMP).
5. In my case the white picture in evince was at 100% zoom 124x124 pixel.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert from a picture to pdf doesn't keep the original

Post by fmw42 »

I am not an expert, but pdf files are vector format and as such do not have a specific resolution. When you imbed an image, even with the images specific size, the pdf still has a vector shell around it with no specific dpi. You need to specify the desired dpi that will make your image stay the same size. I will, however, defer to others more expert in this matter than I.
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: convert from a picture to pdf doesn't keep the original

Post by broucaries »

Any news of this bug report ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert from a picture to pdf doesn't keep the original

Post by fmw42 »

broucaries wrote:Any news of this bug report ?
I do not believe it is a bug. As I mentioned above:

I am not an expert, but pdf files are vector format and as such do not have a specific resolution. When you imbed an image, even with the images specific size, the pdf still has a vector shell around it with no specific dpi. You need to specify the desired dpi that will make your image stay the same size. I will, however, defer to others more expert in this matter than I.
Sworddragon
Posts: 7
Joined: 2012-04-11T11:57:55-07:00
Authentication code: 8675308

Re: convert from a picture to pdf doesn't keep the original

Post by Sworddragon »

broucaries wrote:Any news of this bug report ?
The problem still exists. Using -density 72x72 or nothing will result in 124x124 pixel. Using -density 150x150 will result in 60x60 pixel. But I can't say too if this is a bug or if convert should use at default the correct resolution.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert from a picture to pdf doesn't keep the original

Post by fmw42 »

As I have been trying to say, pdf files have no inherent size in pixels. The size is defined by whatever density you assign to it when you convert it or print it. You cannot display a PDF and expect the size to be the same as the image it came from. It all depends upon how the viewer decides to assign it a density.

Try this:

convert -size 100x100 xc:white white.png

convert white.png white.pdf

identify white.pdf
white.pdf PDF 100x100 100x100+0+0 16-bit Bilevel DirectClass 1.36KB 0.000u 0:00.000

convert -density 72 white.pdf white2.png

identify white2.png
white2.png PNG 100x100 100x100+0+0 8-bit PseudoClass 1c 385B 0.000u 0:00.000


If you use another density value other than 72, the white2.png image will be larger or smaller.
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: convert from a picture to pdf doesn't keep the original

Post by broucaries »

I will try to get a patch for documentation purpose (I suspect pdf A1 does not have this kind of problem).

Bastien
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: convert from a picture to pdf doesn't keep the original

Post by broucaries »

BTW could we by default, determine the screen resolution using the same code then in dpyinfo ? Using something like density auto ?

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

Re: convert from a picture to pdf doesn't keep the original

Post by fmw42 »

broucaries wrote:BTW could we by default, determine the screen resolution using the same code then in dpyinfo ? Using something like density auto ?

Bastien

Sorry I know little more about this. You can perhaps wait to hear back from either Anthony or Magick.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert from a picture to pdf doesn't keep the original

Post by anthony »

Fred (fwm42) has this exactly.

Readers of PDf has no why of knowing the 'ideal' resolution to use to display wrapper raster images exactly 1:1
In fact the image in the PDF may be ulta large and scaled to fit a specific area of a page. It get them 1:1 you would need to create humongous pages!

More so a page could contain multiple images each at a different scale and/or resolution needed for 1:1 viewing.

Basically it is impossible for the simple reason PDF is vector, and not meant to have a specific resolution.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Sworddragon
Posts: 7
Joined: 2012-04-11T11:57:55-07:00
Authentication code: 8675308

Re: convert from a picture to pdf doesn't keep the original

Post by Sworddragon »

Pictures with a different size will have a different size in the pdf document too which is not the original size. How is the information of the size stored?

The main problem is I want to merge a pdf document with .odt files with a document of some pictures. In the result the pictures are more than double so big than the .odt files. My idea was to get the real size in the pdf document and adjusting the pictures. But this doesn't work because the pdf document isn't showing the real size.

So my goal was just to get a consistent size for all files in the pdf document. I doesn't even matter about the real size but I thought there could be a bug with the size on converting. I'm wondering how I can get a pdf document with a consistent size.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert from a picture to pdf doesn't keep the original

Post by anthony »

I don't think you can.

Compression is used for rasters embeded in pdf's so that is variable. and if it is vector, well then it is small but also variable.

The same does for almost any image file format except raw uncompressed data formats.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Sworddragon
Posts: 7
Joined: 2012-04-11T11:57:55-07:00
Authentication code: 8675308

Re: convert from a picture to pdf doesn't keep the original

Post by Sworddragon »

A little time ago I have found the solution for this problem. The argument -page will control a consistent size in the document. In my case I needed just to use "-page A4" to scale the images to the same size as .odt documents.
Post Reply