Tema: Re: php gd resize
Autorius: Justas Butkus
Data: 2009-06-03 15:29:21
Veikianti mintis toliau.
T.y. iš veikiančios funkcijos ir PNG lieka skaidrus.

Gal padės. ;)

Tiesa, kodėl antraštė 'image/jpeg'?


$image_p = imagecreatetruecolor($width, $height);
imagealphablending( $image_p, false );
$colour = imagecolorallocatealpha( $image_p, 0, 0, 0, 127 );
imagefill( $image_p, 0, 0, $colour );
imagesavealpha( $image_p, true );
imagecopyresampled( $image_p, $image, 0, 0, 0, 0, $width,
                    $height, $width_orig, $height_orig);



--
JB

sdf rašė:
> Kaip sumazinti png permatoma paveiksliuka, kad po to vietoj permatomos zonos 
> nebutu juoda?
> 
> Kiek googlinau neradau. Isbandziau visokius imagealphablending ir 
> imagecolorallocatealpha bet nieko nesigavo :(
> 
> Mano kodas:
> <?php
> 
> header('content-type: image/jpeg');
> 
> $percent = 0.5;
> $img = 'water.png';
> 
> $watermark = imagecreatefrompng($img);
> $imgX = imagesx($watermark);
> $imgY = imagesy($watermark);
> 
> $newX = $imgX * $percent;
> $newY = $imgY * $percent;
> 
> $newImage = imagecreatetruecolor($newX, $newY);
> imagecopyresampled($newImage, $watermark, 0, 0, 0, 0, $newX, $newY, $imgX, 
> $imgY);
> 
> imagepng($newImage);
> 
> imagedestroy($watermark);
> imagedestroy($newImage);
> 
> ?> 
> 
>