Jump to content

Resizing images with white background


angelcool

Recommended Posts

Hello phpfreaks community,

 

I am using the following php script to resize .gif images with the GD library; It works very decent:

------------------------------------------------------------------------

$src_img =imagecreatefromgif("bulb_gif.gif");

$srcsize = getimagesize('bulb_gif.gif');

$dest_x = 200;

$dest_y = (200/ $srcsize[0]) * $srcsize[1];//resize ratio.

$dst_img = imagecreatetruecolor($dest_x, $dest_y);

 

// Resize image

imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_x, $dest_y, $srcsize[0], $srcsize[1]);

 

// Output image

header("content-type: image/gif");

imagegif($dst_img);//final image

 

// Destroy images

imagedestroy($src_img);

imagedestroy($dst_img);

 

------------------------------------------------------------------------

 

 

The problem is when resizing images with white background (not transparency), after the script is executed the image background turns not being 100% white (255,255,255). Links:

 

Original .gif file: http://10-network.net/image_thumbial/bulb_gif.gif

Resized image: http://10-network.net/image_thumbial/index.php

 

You can notice the difference between the resized image and the page background. This varies from LCD to LCD, I can tell the difference in my main screen is about 75%, in other screens I have around this is about 90%.

 

Any help will be gently apreciated.

 

Thank you. ;D

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.