Page 1 of 1

Replace Adobe Graphics Server with Imagemagick.

Posted: 2009-08-27T07:35:41-07:00
by swapnonil
Hello Everybody,

Our Digital Asset Management product utilizes Adobe Graphics server to generate thumbnails of popular Adobe file formats like PDF,PSD, EPS and AI. These thumbnails are created so that they can be displayed on a "Preview Window" which pops-up when a user clicks on the name of an uploaded file.

We use Imagemagick for generating thumbnail images from all other formats like png,jpg,gif etc, but use Adobe Graphics Server (AGS) for the remaining 4 file formats named above. We want to replace AGS with Imagemagick so that all thumbnail generation is done by a single software.

It is in context, that were facing some problems
  • Resultant File Format: With AGS, we could just supply it the EPS, PSD,AI or PDF file and it would choose the output file format during thumbnail generation. So the output in case of a transparent AI file would be a gif, but would be jpeg if it's a photograph in PSD format. However with Imagemagick we would have to first determine the nature of the input file before deciding on the what the output file would be. Like if there is transparency give me gif as the output or if there is no transparency then give me jpeg as the output.
    So my question is,
    How do I determine whether an input file has got any transparency or not?
  • Transparency Preservation: How do I preserve the transparency during conversion from say EPS to GIF or AI to GIF?
With Regards
Swapnonil Mukherjee
swapnonil.mukherjee@in.ibm.com

Re: Replace Adobe Graphics Server with Imagemagick.

Posted: 2009-08-27T07:49:22-07:00
by magick
* How do I determine whether an input file has got any transparency or not?
Depends on your interface to ImageMagick. From the MagickCore API, use GetImageType(). From the command line use identify -verbose and it reports the image type.
* Transparency Preservation: How do I preserve the transparency during conversion from say EPS to GIF or AI to GIF?
If you have a modern release of Ghostscript, ImageMagick utilizes the pngalpha device to render transparent EPS images. Check the delegates.xml file and see which device is associated with the ps:alpha tag.

Re: Replace Adobe Graphics Server with Imagemagick.

Posted: 2009-08-27T08:45:53-07:00
by fmw42
How do I determine whether an input file has got any transparency or not?
In command line, the string format will return alpha existence, e.g

convert rose: -format "%A" info:
False

convert rose: -alpha on -format "%A" info:
True

Re: Replace Adobe Graphics Server with Imagemagick.

Posted: 2009-08-27T21:20:28-07:00
by anthony
Note however that you can have an alpha channel but with a fully-opaque image (no alpha channel usage). To check that you will need to look at the minimum value in the alpha channel (if it is enabled).

Re: Replace Adobe Graphics Server with Imagemagick.

Posted: 2009-08-27T22:04:56-07:00
by fmw42
Anthony is correct:

This should work and be better:

is_alpha_on=`convert image -format "%A" info:`
if [ "$is_alpha_on" = "True" ]; then
alpha_val=`convert image -channel A -separate -format "%[fx:mean]" info:`
[ "$alpha_val" != "1" ] && echo "alpha is opaque" || "alpha is not opaque"
else
echo "alpha is off"
fi

Re: Replace Adobe Graphics Server with Imagemagick.

Posted: 2009-08-27T23:31:38-07:00
by swapnonil
Thank you all for the replies,

We use Imagemagick in an interesting way.

We call IM from inside our Java Code using it's Runtime.exec(...) method. My external blog shows the kind of program we are using.
http://mcoder.wordpress.com/2008/02/04/ ... -complete/
We just replace the function argument "args" on line 17. with the complete IM command line like "convert x.jpg to y.jpg".
So my interface to IM is the command line only, though I am able to capture any output using STDOUT. So I can invoke any IM command and get and parse the output if required.

Following the code snippet in the preceding post I was trying to convert the following image from the Ubuntu Terminal.

Image

Running
$]convert pal_bk.png -format "%A" info:
gives me "True" as the output, which is exactly what I want.

Running
$]convert pal_bk.png -channel A -separate -format "%[fx:mean]" info:
gives me 0.47108, which means the image is neither fully transparent nor opaque.

and running the same command on this opaque file http://drop.io/5f4xvsd gives me "0" as the output. So I guess, this means that the file is opaque.

So far so good.
Now that I have determined that file is pal_bk.png is about 0.47 transparent, I want to convert it into pal_bk.gif and preserve the transparency at the same time.
But when I issue
$]convert pal_bk.png pal_bk.gif
I get a gif image which does not preserve the transparency.
How do I solve this problem?

With Regards
swapnonil.mukherjee@in.ibm.com


Thanks

Re: Replace Adobe Graphics Server with Imagemagick.

Posted: 2009-08-28T09:03:05-07:00
by fmw42
gif does NOT support partial transparency. you will need to use png