Flatten transparency

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
marcher

Flatten transparency

Post by marcher »

Hi.

I am using ghostscript and imagemagick to convert pdf-files to jpg image files. Unfortunatly I am experiencing problems with some pdf files that contains a lot of transparent objects. In theese case the conversion process only generates blank output :(

But when I optimize the pdf files in acrobat professional (the problem is solved)

To skip this step in acrobat professional I was wondering if there was a way to use imagemagick to flatten transparency?

Theese are the settings I am using for imagemagick:

-density 250 -units PixelsPerInch -define pdf:use-cropbox=true -quality 90% -colorspace RGB -layers flatten

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

Re: Flatten transparency

Post by fmw42 »

marcher wrote:Hi.

I am using ghostscript and imagemagick to convert pdf-files to jpg image files. Unfortunatly I am experiencing problems with some pdf files that contains a lot of transparent objects. In theese case the conversion process only generates blank output :(

But when I optimize the pdf files in acrobat professional (the problem is solved)

To skip this step in acrobat professional I was wondering if there was a way to use imagemagick to flatten transparency?

Theese are the settings I am using for imagemagick:

-density 250 -units PixelsPerInch -define pdf:use-cropbox=true -quality 90% -colorspace RGB -layers flatten

-Thanks
Don't know if this will help. but have you tried -flatten rather than -layers flatten
marcher

Re: Flatten transparency

Post by marcher »

Hi.

yes I have tryed this setting too, but unfortunatly there wasent any difference in the result.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Flatten transparency

Post by anthony »

-flatten and -layers flatten are the same thing. The former is for backward compatibility and convenience.

I hope you are not trying to go from PDF to PDF, that is not a good thing to do with IM as that it outside its scope.
See A word about Vector Image formats
http://www.imagemagick.org/Usage/formats/#vector
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
marcher

Re: Flatten transparency

Post by marcher »

Hi Anthony.

Thanks for replying to my post. No I'm not trying to go from PDF to PDF, it's from PDF to jpg.

After testing multiple settings I have discovered that if I remove the -density 250 or lower it to -density 50 the pages which gave me problems are created unfortunatly the quality is very low and jagged. As mentioned earlier then the problem seems to appear when the PDF page contains a lot of transparent objects.

The pages that dosent contain a lot of transparent objects are processed without any problems by using the settings described in my previoius post.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Flatten transparency

Post by anthony »

JPEG can't handle transparency. You will need to underlay some background color to the image before saving to JPEG.

The -flatten mentioned is the typical method to do this.

Code: Select all

    convert ....  -background white -flatten  image.jpg
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply