Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 14th July 2008, 09:43
Angelito Angelito is offline
Junior Member
 
Join Date: Jan 2008
Location: Los Angeles,CA (US)
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Resizing images with white background using php and GD.

Hello community,

I am using the following php script to resize .gif images using 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.
Reply With Quote
Sponsored Links
  #2  
Old 14th July 2008, 11:57
burschik burschik is offline
Junior Member
 
Join Date: May 2008
Posts: 24
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You are using an interpolated resizing operation. Either use a non-interpolating resizing operation instead, or do not create a true colour destination image.
Reply With Quote
  #3  
Old 1st August 2013, 19:03
metalass metalass is offline
Junior Member
 
Join Date: Aug 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

Quote:
Originally Posted by burschik View Post
You are using an interpolated resizing operation. Either use a non-interpolating resizing operation instead, or do not create a true colour destination image.
Hello!

Can you clarify what does it mean, non-interpolating resizing. Does it means to use imagesetinterpolation function (http://www.php.net/manual/en/functio...erpolation.php) or another php function?

Can you write an example of code, please!
It's very important. I have not found any other discussions of this problem all around the Internet.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:47.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.