Skip to content

background color for jpeg from transparent png ? #194

patie opened this Issue Jan 31, 2013 · 3 comments

4 participants

patie commented Jan 31, 2013

when i upload transparent png - its uploaded jpeg with black background

can i set this background color? thanks


Hi, yes you can with something like:


$image      = getUploadedImage();
$background = new Imagine\Image\Color('#fff');
$topLeft    = new Imagine\Image\Point(0, 0);
$canvas     = $imagine->create($image->getSize(), $background);

    ->paste($image, $topLeft)

Closing this one as it seems already solved

rayrigam commented Jul 7, 2015

Shouldn't the default background be white when converting from transparent png to jpg? How can I tell if the uploaded png has a transparent background so that I only set the canvas as described above in those cases for converting to jpg?
There is a suggested way here:
Or should I just do the above pasting on a white canvas for all png images uploaded? Would that have a significant impact on memory used and performance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.