Jump to content

Imagecolortransparent() trouble


ch4rli3

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
Share on other sites

This is a wild guess, because I can't see anything else that is wrong if it works on your server with the exact same code, but are you sure the script are able to get to get the images using the function imagecreatefrompng()?

 

 

Link to comment
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

 

Link to comment
Share on other sites

Might be helpful, might be just a waste of time, but maybe if you create the image first...

imagecreastetruecolor()

and then copy it over.

Might also be you must use one of these:

imagesavealpha()

imagealphablending()

Link to comment
Share on other sites

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.