Page 1 of 1
keep transparent background
Posted: 2009-01-25T12:37:28-07:00
by mindstorm
When I convert ai, eps, pdf, psd or png files, they are created with a white background, instead of maintaining their original transparent background. How can I make them maintain their original transparency? I have tried '-alpha On' with no luck. I can't use color removal because the images being uploaded will come in all colors and I would risk removing some of that data.
Please Help
Thanks!
Re: keep transparent background
Posted: 2009-01-25T12:46:40-07:00
by Bonzo
When I convert ai, eps, pdf, psd or png files
what format are you converting to ?
How are you doing it Windows, linux, php etc?
Re: keep transparent background
Posted: 2009-01-26T19:18:18-07:00
by anthony
Try setting -background none before reading.
NOTE some vector images actually 'draw' the background as well. Caution needed.
Re: keep transparent background
Posted: 2009-01-28T20:23:24-07:00
by mindstorm
Thanks Anthony. I'm converting to png on an apache server. Could the order of operation be an issue? I'm flattening for psds. Does that need to be done before setting background none?
$thumb = '/thumb_'.$file_basename.'.png';
$cmd = '/usr/local/bin/convert '.$img.' -resize 200 -flatten -background none '.$thumb;
I have also notice that using -transparent white doesn't always work with vectors, as you mentioned with drawing the background. Is this due to a saving preference?
Update:
Moving -flatten after setting background fixed the issue with most files.
Re: keep transparent background
Posted: 2009-01-28T21:08:23-07:00
by anthony
The -background none was for vector images as should have been set BEFORE reading such an image. In most cases this will have the image draw on a transparent background rather than the 'white' default.
Remember reading an image is actually itself just a 'operation' in IM, one that does not need some type of -read type operator.
If done before outputing, as you specified, it will only effect image file formats that have a 'background setting, such as GIF's, though few programs (other than IM) will make use of such a setting that was saved with the image file format, it is typically ignored!
ASIDE....
IM only uses it if -background has NEVER been set or is turned off (using +background ) before reading the image. In other words only in special and uncommon situations.
This by the way does cause some confusion in those rare situations as basically IM does not really have an idea of a 'global' setting for background, as a separate entity to individual images 'background meta-data' setting, even though it seems like it does.
I am wanting to see the idea of a proper 'global' setting as separate to individual image meta-data, added, but this my require a major version change.