Re: [PHP] Transparent image resizing using php 4.4.x
On Sun, June 10, 2007 12:08 pm, tedd wrote: > At 1:12 AM +0500 6/10/07, Sukhwinder Singh wrote: >>-snip- >>Could anyone please provide me a solution which works using php 4.4.x >> >>Sukhwinder Singh > > Instead of: > > imagecolortransparent($img_resized, $transparent); > > try: > > imagecolortransparent($img,imagecolorat($img,0,0)); > > Look-up imagecolorat(). I suspect that in various versions of GD, you may have troubles switching from a GIF (256 color pallette) to TrueColor (millions of colors) and back again... GD may well attempt to anti-alias, de-speckle, or who knows what in either of those transitions. I would suggest that you create images with the pallette[s] you want, and see if you get more consistent results. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Transparent image resizing using php 4.4.x
At 12:42 AM +0500 6/11/07, Sukhwinder Singh wrote: try: imagecolortransparent($img,imagecolorat($img,0,0)); Look-up imagecolorat(). I had tried it earlier. As I have written in my other emails. I have tried almost all solutions. I am really wondering that no one has every faced any such problem. I'll try what you have suggested. But I think I have already and it didn't work. But I'll let you know after trying again. Sukhwinder Singh I've seen it mentioned before that down-sizing a transparent image presents a problem to the algorithm that calculates what colors are more relevant. As such, if you redefine the color that you want to be transparent at 0,0 -- then the imagecolortransparent() function has an easier time of it. At least, that's my take on it -- could be wrong. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Transparent image resizing using php 4.4.x
try: imagecolortransparent($img,imagecolorat($img,0,0)); Look-up imagecolorat(). I had tried it earlier. As I have written in my other emails. I have tried almost all solutions. I am really wondering that no one has every faced any such problem. I'll try what you have suggested. But I think I have already and it didn't work. But I'll let you know after trying again. Sukhwinder Singh - Original Message - From: "tedd" <[EMAIL PROTECTED]> To: "Sukhwinder Singh" <[EMAIL PROTECTED]>; Sent: Sunday, June 10, 2007 10:08 PM Subject: Re: [PHP] Transparent image resizing using php 4.4.x At 1:12 AM +0500 6/10/07, Sukhwinder Singh wrote: -snip- Could anyone please provide me a solution which works using php 4.4.x Sukhwinder Singh Instead of: imagecolortransparent($img_resized, $transparent); try: imagecolortransparent($img,imagecolorat($img,0,0)); Look-up imagecolorat(). Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Transparent image resizing using php 4.4.x
At 1:12 AM +0500 6/10/07, Sukhwinder Singh wrote: -snip- Could anyone please provide me a solution which works using php 4.4.x Sukhwinder Singh Instead of: imagecolortransparent($img_resized, $transparent); try: imagecolortransparent($img,imagecolorat($img,0,0)); Look-up imagecolorat(). Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Transparent image resizing using php 4.4.x
On 6/9/07, Sukhwinder Singh <[EMAIL PROTECTED]> wrote: I have tried many ways to resize a transparent gif but it works on my local server which has php 5.1.6 but none works using php 4.4.x Also the below works when using imagecopyresized and not imagecopyresampled. I have no clue why that is the case as imagecopyresampled is supposed to produce better results. I have php version 5.1.6 locally (windows) and this works: But the above doesn't work using php 4.4.x and creates images with lots of white lines/dots in it. Some pixel is transparent and some it isn't. I have no knowedge about image manuplation like alpha channels etc. Could anyone please provide me a solution which works using php 4.4.x Sukhwinder Singh I don't think it has anything to do with the PHP version, but with the version of the GD library used. What version of GD are you using on both systems? You can see it with phpinfo: Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Transparent image resizing using php 4.4.x
On Sunday 10 June 2007 04:12, Sukhwinder Singh wrote: > $img_resized = ImageCreateTrueColor ($img_new_width, $img_new_height); > But the above doesn't work using php 4.4.x and creates images with lots > of white lines/dots in it. Some pixel is transparent and some it isn't. > I have no knowedge about image manuplation like alpha channels etc. > Could anyone please provide me a solution which works using php 4.4.x Are you sure you're getting a transparent image at all? From what I understand GIF does not support more than 8 bits. Why not use PNG instead? -- Crayon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Transparent image resizing using php 4.4.x
I have tried many ways to resize a transparent gif but it works on my local server which has php 5.1.6 but none works using php 4.4.x Also the below works when using imagecopyresized and not imagecopyresampled. I have no clue why that is the case as imagecopyresampled is supposed to produce better results. I have php version 5.1.6 locally (windows) and this works: $img_resized = ImageCreateTrueColor ($img_new_width, $img_new_height); // new image to create $o_img = ImageCreateFromGif($source_file_path); // source file $trans_arr = get_transparency($source_file_path); // function given below if (isset($trans_arr['red']) && isset($trans_arr['green']) && isset($trans_arr['blue'])) { $transparent = imagecolorallocate($img_resized, $trans_arr['red'], $trans_arr['green'], $trans_arr['blue']); imagefilledrectangle($img_resized, 0, 0, $img_new_width, $img_new_height, $transparent); imagecolortransparent($img_resized, $transparent); } // I tried follwoing instead of that get_transparency function and above codee. But same result /*$transparent = imagecolorallocate($img_resized, 255, 255, 255); imagefilledrectangle($img_resized, 0, 0, $img_new_width, $img_new_height, $transparent); imagecolortransparent($img_resized, $transparent); */ imagecopyreresized($img_resized, $o_img, 0 , 0 , 0 , 0, $img_new_width, $img_new_height, $img_orig_width, $img_orig_height); ImageGif($img_resized, $new_file_path); // this function I created by copying code from somewhere on internet function get_transparency($img_file) { $ret = array(); $fp = fopen($img_file, "rb"); $result = fread($fp, 13); $colorFlag = ord(substr($result,10,1)) >> 7; $background = ord(substr($result,11)); if ($colorFlag) { $tableSizeNeeded = ($background + 1) * 3; $result = fread($fp, $tableSizeNeeded); $ret['red'] = ord(substr($result, $background * 3, 1)); $ret['green'] = ord(substr($result, $background * 3 + 1, 1)); $ret['blue'] = ord(substr($result, $background * 3 + 2, 1)); } fclose($fp); return $ret; } ?> But the above doesn't work using php 4.4.x and creates images with lots of white lines/dots in it. Some pixel is transparent and some it isn't. I have no knowedge about image manuplation like alpha channels etc. Could anyone please provide me a solution which works using php 4.4.x Sukhwinder Singh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php