Page 1 of 1

[Resolved] Page misalignment converting PNG to PDF

Posted: 2016-06-11T09:05:08-07:00
by HelenF
Hi,

I had pages in PNG format, edited in Kolourpaint, and was trying to use ImageMagick to assemble them into a PDF file with one image per page. In the generated PDF file, some of the pages were correct, but some of the pages had uneven margins (not all in the same direction).

I was using ImageMagick 6.8.8-10 Q16 i686 2015-03-10 on Fedora 22 (viewing in Evince). Downloaded and installed the updated ImageMagick-7.0.1-10-Q8-x64-dll.exe on Windows 10 (and viewed with Adobe Reader) and it behaved the same.

This could be a Kolourpaint bug, or a feature, but here seems like the place to check.

Here is a test image that shows the behaviour when converted to a 1-page PDF by itself:
https://www.dropbox.com/s/tksin9t7wn8c2 ... n.zip?dl=1

Drawing of the results:
Image

Code: Select all

convert test.png test.pdf
The image is shifted to the south-west on the page, and because there are no added margins, two of the edges are cut off (1).

Code: Select all

convert test.png test.bmp
convert test.bmp test.pdf
This is OK (2). So if there was a problem with the PNG file, it's not there in the BMP.

Code: Select all

convert test.bmp test2.png
convert test2.png test.pdf
This is OK (2). So if there was a problem with the PNG file, it was fixed by converting to BMP and back.

Code: Select all

convert -flip test.png test2.png
convert test2.png test.pdf
The image is shifted to the north-west on the page (3). So if there was a problem with the PNG file, it was preserved (and flipped) by the flip operation.

Re: Page misalignment converting PNG to PDF

Posted: 2016-06-11T09:38:15-07:00
by snibgo
"identify test.png" shows the file has offsets in x and y. "+repage" removes these.

Code: Select all

convert test.png +repage out.pdf

Re: Page misalignment converting PNG to PDF

Posted: 2016-06-12T06:32:21-07:00
by HelenF
Thanks for the help. I can make my document now :)

I remembered that I rotated some of the pages with ImageMagick before editing them. Looks like that operation added the offsets without me noticing. Kolourpaint just preserves the offsets when editing the file. And converting to PDF finally makes them visible. This is equivalent (though the result is less obvious when I haven't cropped the edges):

Code: Select all

convert -rotate -0.5 anyimage.png anytest.png
convert anytest.png anytest.pdf
I noticed something else with the test image and example commands in the first post. With the first two examples on my Windows setup, the magenta colour is dulled significantly. Why is this? With the last two examples on my Windows setup, and all four on my Fedora setup, it stays the same.

Re: Page misalignment converting PNG to PDF

Posted: 2016-06-12T09:02:59-07:00
by snibgo
Your command order is wrong. You should read the input, then do whatever operation on it you want, then wite the output.

Rotating creates an offset. If you don't need the offset, you can immediately remove it, eg:

Code: Select all

convert anyimage.png -rotate -0.5 +repage anytest.png
convert anytest.png anytest.pdf

convert anyimage.png -rotate -0.5 +repage anytest.pdf
HelenF wrote:With the first two examples on my Windows setup, the magenta colour is dulled significantly.
What tells you "the magenta colour is dulled significantly"? I can't see that. "-unique-colors" shows all colours are unchanged.

Re: Page misalignment converting PNG to PDF

Posted: 2016-06-14T09:15:48-07:00
by HelenF
The order was because in reality, there were manual operations in between.

Thanks, I will immediately remove the offsets next time.

With the first two examples, the magenta looked wrong in Adobe Reader 10.1.16. But I updated Adobe Reader (much overdue) and the same PDF files look the right colour now.