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

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?".
Post Reply
jauson
Posts: 15
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

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

Post by jauson » 2017-09-13T13:38:24-07:00

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

User avatar
fmw42
Posts: 22081
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2017-09-13T14:02:14-07:00

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.

snibgo
Posts: 9379
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo » 2017-09-13T14:28:05-07:00

"-rotate" creates canvas offsets. Use "+repage" to remove them.
snibgo's IM pages: im.snibgo.com

jauson
Posts: 15
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

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

Post by jauson » 2017-09-13T15:30:36-07:00

i believe the +repage did the trick. thank you.

Post Reply