Page 1 of 1

Flatten transparency

Posted: 2008-10-28T04:57:10-07:00
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

Re: Flatten transparency

Posted: 2008-10-28T08:45:10-07:00
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

Re: Flatten transparency

Posted: 2008-10-28T08:52:20-07:00
by marcher
Hi.

yes I have tryed this setting too, but unfortunatly there wasent any difference in the result.

Re: Flatten transparency

Posted: 2008-10-28T23:50:03-07:00
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

Re: Flatten transparency

Posted: 2008-10-29T04:59:54-07:00
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.

Re: Flatten transparency

Posted: 2008-10-29T16:18:28-07:00
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