2

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.stack.imgur.com/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);
?>
Eric
  • 95,302
  • 53
  • 242
  • 374
homework
  • 4,987
  • 11
  • 40
  • 50

2 Answers2

3

imagealphablending and imagesavealpha.

poke
  • 369,085
  • 72
  • 557
  • 602
0

See this post: PNG Image Transparency in PHP GD

Community
  • 1
  • 1
Joel
  • 2,654
  • 6
  • 31
  • 46