FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Scaling image is losing background transparency
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Scaling image is losing background transparency [message #171670 is a reply to message #171660] Sat, 15 January 2011 03:07 Go to previous message
Chuck Anderson is currently offline  Chuck Anderson
Messages: 63
Registered: September 2010
Karma:
Member
laredotornado(at)zipmail(dot)com wrote:
> Hi,
>
> I'm using PHP 5 and trying to scale png images programatically. Here
> is what I'm doing ...
>
> $src_img = imagecreatefrompng($imagefile);
> $hw = getimagesize($imagefile);
> $new_w = $w;
> $new_h = $hw["1"]/($hw["0"]/$w);
> $dst_img = @imagecreatetruecolor($new_w, $new_h);
> if(!$dst_img) {
> $dst_img = imageCreate($new_w, $new_h);
> }
> imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,
> $new_h,imagesx($src_img),imagesy($src_img));
> imagepng($dst_img);
>
> The problem is my scaled png image loses its background transparency.
> The short of this is, does anyone know how to scale PNG images
> effectively and what other information can I provide to help
> troubleshoot this further?
>
> Thanks, - Dave
>

When I was doing transparent png image overlays (on the fly, scaled
watermarks on top of web site images), I found that I had to use
imagecopyresampled as opposed to imagecopymerge or the transparent
overlay would lose it's transparency (sound familiar?). Try using
imagecopyresampled instead of imageycopyresized.

I made a very brief note about it here -
http://cycletourist.com/temp/watermark.php

--
————————————————————————— ————
Chuck Anderson • Boulder, CO
http://cycletourist.com
Turn Off, Tune Out, Drop In
————————————————————————— ————
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: having better solution to promote your products.
Next Topic: newbie: Zend or PEAR supported on web hosting company?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 00:15:43 GMT 2024

Total time taken to generate the page: 0.24823 seconds