How to rotate pdf and undo rotating? Gives unexpected 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?".
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: How to rotate pdf and undo rotating? Gives unexpected results.

Post by magick »

Crosses.pdf includes a profile that is incompatible with the PDF output type. The input is sRGB and the output is gray alpha. You have two choices, strip the profile or force sRGB output with +profile sRGB or -type sRGB. Place either just before the output image filename on the command-line. Why does ImageMagick not do that automatically? Because the "user is king." ImageMagick assumes the user knows what they are doing and just follows the user instructions as defined by the command-line arguments.
jauson
Posts: 36
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Re: How to rotate pdf and undo rotating? Gives unexpected results.

Post by jauson »

Like this?

Code: Select all

convert -verbose -density 288 -colorspace sRGB crosses.pdf  -alpha remove +profile sRGB out-2-x.pdf
convert -verbose -density 288 -colorspace sRGB out-2-x.pdf  -alpha remove +profile sRGB out-2-x-2nd-save.pdf

It's still producing the same results.
jauson
Posts: 36
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Re: How to rotate pdf and undo rotating? Gives unexpected results.

Post by jauson »

magick wrote: 2018-09-15T07:30:09-07:00 Crosses.pdf includes a profile that is incompatible with the PDF output type. The input is sRGB and the output is gray alpha. You have two choices, strip the profile or force sRGB output with +profile sRGB or -type sRGB. Place either just before the output image filename on the command-line. Why does ImageMagick not do that automatically? Because the "user is king." ImageMagick assumes the user knows what they are doing and just follows the user instructions as defined by the command-line arguments.
I tried both, but neither works.

Code: Select all

convert -verbose -density 288 -colorspace sRGB crosses.pdf  -alpha remove  -type sRGB out-2-x.pdf
convert -verbose -density 288 -colorspace sRGB out-2-x.pdf  -alpha remove  -type sRGB out-2-x-2nd-save.pdf
Throws an error:

Code: Select all

convert.exe: unrecognized image type `sRGB' @ error/convert.c/ConvertImageCommand/3085.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to rotate pdf and undo rotating? Gives unexpected results.

Post by fmw42 »

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli
jauson
Posts: 36
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Re: How to rotate pdf and undo rotating? Gives unexpected results.

Post by jauson »

GS 9.24 and Version: ImageMagick 6.9.10-11 Q16 x64 2018-08-29 Windows 8.1
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to rotate pdf and undo rotating? Gives unexpected results.

Post by fmw42 »

This fails for me on IM 6.9.10.11 Q16 Mac OSX Sierra. The png files are wrong.

Code: Select all

convert crosses.pdf tmp.pdf
convert tmp.pdf tmp.png

But adding -strip works fine for me

Code: Select all

convert crosses.pdf -strip tmp.pdf
convert tmp.pdf tmp.png

This also works by adding +profile "*"

Code: Select all

convert crosses.pdf +profile "*" tmp.pdf
convert tmp.pdf tmp.png
jauson
Posts: 36
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Re: How to rotate pdf and undo rotating? Gives unexpected results.

Post by jauson »

That does produce the expected result. I noticed the 2nd save gets a little lighter, bigger in size.

Code: Select all

# increase in size
convert -verbose -density 288 -colorspace sRGB crosses.pdf  -alpha remove +profile '*' out-2-x.pdf
# lighter increase in size
convert -verbose -density 288 -colorspace sRGB out-2-x.pdf  -alpha remove +profile '*' out-2-x-2nd-save.pdf
# same as above
convert -verbose -density 288 -colorspace sRGB out-2-x-2nd-save.pdf  -alpha remove +profile '*' out-2-x-3nd-save.pdf

Also, it seems I can't undo the damage of outputting a previously saved pdf without this profile or strip command.

Code: Select all

convert -verbose -density 288  -colorspace sRGB crosses.pdf  -alpha remove out-2-x.pdf
convert -verbose -density 288  -colorspace sRGB out-2-x.pdf  -alpha remove +profile '*' out-2-x-2nd-save.pdf
convert -verbose -density 288  -colorspace sRGB out-2-x.pdf  -alpha remove -strip out-2-x-3rd-save.pdf
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to rotate pdf and undo rotating? Gives unexpected results.

Post by fmw42 »

The -strip removes more meta data than the +profile. So it could produce differences.
jauson
Posts: 36
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Re: How to rotate pdf and undo rotating? Gives unexpected results.

Post by jauson »

Neither +profile nor -strip can fix the output that doesn't use either.
jauson
Posts: 36
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Re: How to rotate pdf and undo rotating? Gives unexpected results.

Post by jauson »

thanks fmw42 for your help.
Post Reply