Page 1 of 1

Rotate pdf page 45 degrees, weird rotation and white space in results

Posted: 2017-09-13T13:38:24-07:00
by jauson
I'm trying to rotate a pdf page by (some degrees) 45 degrees for example, and saving it back to pdf, and the result is creating weird white spacing and moving it off page inside the pdf result, if I save the output as png it works as expected.

Version: ImageMagick 6.9.9-10 Q16 x64 2017-08-27

Code with pdf to pdf used:

Code: Select all

convert -density 288 -quality 100 sample.pdf[0] -rotate 45 -alpha remove sample-rot45.pdf
Same results when using png to pdf.

Example with image (same as the pdf):
Original:
Image

To png rotated:

Code: Select all

convert.exe cat128.png -rotate 45 cat128rot45.png
Image

To pdf rotated:

Code: Select all

convert.exe cat128.png -rotate 45 cat128rot45.pdf
Image

To png from rotated pdf:

Code: Select all

 convert.exe cat128rot45.pdf cat128rot45frompdf.png
Image

Re: Rotate pdf page 45 degrees, weird rotation and white space in results

Posted: 2017-09-13T14:02:14-07:00
by fmw42
Please post your PDF. I suspect it might have virtual canvas offsets. Try

Code: Select all

convert -density 288  sample.pdf[0] +repage -background white -alpha remove -rotate 45 sample-rot45.pdf
I am not sure what -quality 100 is doing unless you have JPG compression in your PDF.

Re: Rotate pdf page 45 degrees, weird rotation and white space in results

Posted: 2017-09-13T14:28:05-07:00
by snibgo
"-rotate" creates canvas offsets. Use "+repage" to remove them.

Re: Rotate pdf page 45 degrees, weird rotation and white space in results

Posted: 2017-09-13T15:30:36-07:00
by jauson
i believe the +repage did the trick. thank you.