Jump to content

ImageCopy Color and Resolution Loss


Patriot

Recommended Posts

1-3.gif

 

The gift on the right side is dynamically placed on the background using image copy.  Before the copy, the image of the gift looks fine.  Now it loses color and turns pinkish.

 

CODE:

	     
$banner     = imagecreatefromgif("tbg1.gif");
$prizeimage = imagecreatefromgif("tgt1.gif");
$fontcolor  = imagecolorallocate($banner, 0, 0, 0);
imagettftext($banner, 13, 0, 7, 74, $fontcolor, "myriadregpro.otf", "Stuff: " . $prize);
imagecopyresampled($banner, $prizeimage, 312, 4, 0, 0, 84, 97, 84, 97);

 

Does anyone know what is wrong?

Link to comment
https://forums.phpfreaks.com/topic/95286-imagecopy-color-and-resolution-loss/
Share on other sites

howdy, i lost the previous thread on this. can you provide both original images and i'll take a shot at getting one on the other without losing color/resolution/etc.? if you can just post a link to both originals or whatever, i'll hack the code together here and (hopefully) figure out the problem.

 

see if this works for you. i don't have the font, so i left it out. shouldn't make a difference, but you should un-comment it for testing.

 

<?php
$complete_img = imagecreatetruecolor(400,105);
$banner     = imagecreatefromgif("tbg1.gif");
$prizeimage = imagecreatefromgif("tgt1.gif");

//$fontcolor  = imagecolorallocate($complete_img, 0, 0, 0);
//imagettftext($complete_img, 13, 0, 7, 74, $fontcolor, "myriadregpro.otf", "Stuff: " . $prize);

imagecopy($complete_img, $banner, 0, 0, 0, 0, 400, 105);
imagecopy($complete_img, $prizeimage, 312, 4, 0, 0, 84, 97);

header('Content-type: image/jpeg');
imagejpeg($complete_img, null, 100); // Finished image is $complete_img
?>

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.