Jump to content

Recommended Posts

Hi guys,

i have trouble with my imagecolortransparent from gd library. On one server everything works fine, but if i moved it to hosting server it not works.

 

here's code:

 

<?php

 

$width = 0;

$height = 0;

list($width, $height, $type, $attr) = getimagesize('img/design/GA_preview.png');

if(!$image=imagecreatefrompng('img/design/GA_preview.png')){

        echo "Error while loading image";

        exit;

}

 

$color_1 = imagecolorat($image, 50,50);

$result = imagecolortransparent($image,$color_1);

if(!$bg=imagecreatefrompng('img/material/B1_E475_preview.png')){

              echo "Error while loading image";

              exit;

}

imagecopy($bg, $image, 0,0,0,0,$width, $height);

Header("Pragma: No-cache");

Header("Cache-Control: No-cache, Must-revalidate");

Header("Expires: ".GMDate("D, d M Y H:i:s")." GMT");

header("Content-type: image/jpeg");

imagejpeg($bg, "", 100);

imagedestroy($image);

imagedestroy($bg);

 

 

?>

 

 

this is how it should look: http://212.111.5.196:8088/graspo/diar_vyvoj/test.php

 

and this is how it looks: firemnidiar.graspo.com/diar/test.php

 

for better solving of my problems here are phpinfo files on both servers:

 

working: http://212.111.5.196:8088/graspo/diar_vyvoj/info.php

 

not working: firemnidiar.graspo.com/diar/phpinfo.php

Link to comment
https://forums.phpfreaks.com/topic/267103-imagecolortransparent-trouble/
Share on other sites

Try using imagecopymerge instead of imagecopy.  It should have the effect your after.  As for why it works on one server but not the other, I don't know.  One of them is compiled with the bundled GD library while the other appears to use the system library.  There must be some small difference between the two that is causing the different output

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.