homework
homework

Reputation: 5087

Output PNG images with transparency in PHP

How do you correctly output PNG images with PHP so their shading, and other transparent effects don't fail.

alt text

seems to be outputting as

https://i.sstatic.net/AoIdy.png

...is there a way so this doesn't happen?

I merged two images together.

<?php
// Create image instances
$dest = imagecreatefrompng('vinyl.png');
$src = imagecreatefromjpeg('cover2.jpg');

// Copy and merge
imagecopymerge($dest, $src, 10, 10, 0, 0, 180, 180, 100);

// Output and free from memory
header('Content-Type: image/png');
imagepng($dest);

imagedestroy($dest);
imagedestroy($src);
?>

Upvotes: 2

Views: 794

Answers (2)

Joel
Joel

Reputation: 2824

See this post: PNG Image Transparency in PHP GD

Upvotes: 0

poke
poke

Reputation: 387507

imagealphablending and imagesavealpha.

Upvotes: 3

Related Questions