Page 1 of 1

GIF Image Compositing with Opacity? [magick++]

Posted: 2007-02-15T19:09:31-07:00
by mankyd
I am sure this has been asked before but the search feature doesn't allow querying for "gif" :(

I've written a program generates an image based on my users' input, composites their input over top with a slight opacity, and outputs its as a jpeg. Most of the time, this works no problem (99% of my users upload jpegs or pngs)

The problem is that I have a user on my website that is trying to create an image from a gif (a gif with a transparent color, to be specific.) For whatever reason, when my program blended their image over top, it didn't pay heed to the opacity setting. It simply kept the transparent color of the gif and made everything else opaque. How do I fix this?

Code: Select all

if (_original_opacity != 0) {  //original opacity is set to 10
	_source_img->modifyImage();
	_source_img->opacity(int(TransparentOpacity * float(100 - _original_opacity) / 100.));
	_source_img->zoom(Geometry(out.columns(), out.rows()));
	out.composite(*_source_img, 0, 0, DissolveCompositeOp);
}

input: http://mozaiq.org/mozaiq/0/102.8724744.source.gif
erroneous output: http://mozaiq.org/mozaiq/0/102.8724744.9.jpg

Re: GIF Image Compositing with Opacity? [magick++]

Posted: 2007-02-18T22:29:04-07:00
by anthony
If you don't want the transparency, you will need to overlay it on some background.
See IM Examples GIF file format, 'Solid background color'
http://www.imagemagick.org/Usage/formats/#bgnd

It may be blend is not understnding a 'index' image, so type using resting the images type.


Remember JPEG does NOT understand transparency, so don't have any when you are ready to save it.