killerb Posted August 13, 2006 Share Posted August 13, 2006 . . . and why can't i find anything about it already!!?I have this process:[code]<?phpmove_uploaded_file($_FILES[$name]['tmp_name'],$dest);$image_p = imagecreatetruecolor($tile_oblique_width, $h);$image = imagecreatefromgif($dest);imagecopyresampled($image_p, $image, 0, 0, 0, 0, $tile_oblique_width, $h, $dims['0'], $dims['1']);$image = imagegif($image_p,$dest);?>[/code]Problem is that I get a nasty black background where it should be transparent.If I just move_uploaded_file without resizing, it is transparent as I want.Is there actually a way to do this? - There must be!Cheers. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 13, 2006 Share Posted August 13, 2006 [code]<?php// The file$filename = 'test.jpg';$percent = 0.5;// Content typeheader('Content-type: image/jpeg');// Get new dimensionslist($width, $height) = getimagesize($filename);$new_width = $width * $percent;$new_height = $height * $percent;// Resample$image_p = imagecreatetruecolor($new_width, $new_height);$image = imagecreatefromjpeg($filename);imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);// Outputimagejpeg($image_p, null, 100);?> [/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted August 13, 2006 Share Posted August 13, 2006 [quote="manual"]The transparent color is a property of the image, transparency is not a property of the color.[/quote]You need to set it for the new image[code]<?php$ct = imagecolorat($image_p, 0,0);imagecolortransparent($image_p, $ct);imagegif($image_p, $dest);imagedestroy($image_p); // don't forget these linesimagedestroy($image);?>[/code] Quote Link to comment Share on other sites More sharing options...
killerb Posted August 13, 2006 Author Share Posted August 13, 2006 Well, yeah, jpeg is working fine, of course it doesn't give me transparency. Adding imagecolortransparent works for .png, but not for gif. As well, the png is aliased to black matt. It is pretty clear that this is a realm of PHP I need to study, so I will do that sometime soon.For the meantime, I must get on with it. This project is getting bigger and bigger by the day. Quote Link to comment Share on other sites More sharing options...
Barand Posted August 13, 2006 Share Posted August 13, 2006 If creating gif or png, try imagecreate instead of imagecreatetruecolor Quote Link to comment Share on other sites More sharing options...
killerb Posted August 13, 2006 Author Share Posted August 13, 2006 Yay its working! Cheers Mate! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.