Thumbnailing - preserve 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
antony96
Posts: 1
Joined: 2018-05-11T07:21:27-07:00
Authentication code: 1152

Thumbnailing - preserve transparency

Post by antony96 » 2018-05-11T07:23:50-07:00

Hi all,

I'm having a heck of a time preserving transparency when converting from vector formats to PNG thumbnails. I've tried matching the read-in colourspace, adding the "-background none" flag, setting the "-transparent cmyk(0,0,0,0)" flag - "cmyk(0,0,0,0)" being the value of "Transparent" when I call identify -verbose.

I can convert from a PNG with a transparency to another PNG with transparency - that works as expected - but when converting from an EPS, the background goes white.

Bonzo
Posts: 2961
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Thumbnailing - preserve transparency

Post by Bonzo » 2018-05-11T07:37:00-07:00

IM version number?
Operating system?
API or language you are using?
Link to sample image?

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

Re: Thumbnailing - preserve transparency

Post by fmw42 » 2018-05-11T10:15:25-07:00

Without having your EPS image to work with it is hard to know exactly, but try

Code: Select all

convert -density X -colorspace sRGB image.eps image.png
X is the desired density such as 72 nominal, but for larger outputs use 150 or 300. You need to convert to srgb via -colorspace, since the ghostscript delegate does not handle transparent cmyk EPS files. I am guessing from what you wrote that the EPS is CMYK. Also your delegates.xml file should have an entry

<delegate decode="ps:alpha" stealth="True" command="&quot;gs&quot; -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pngalpha&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;"/>

which uses sDEVICE=pngalpha


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

For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown

Post Reply