nie mogę na końcu tego skryptu ustawić przezroczystości dla żółtego koloru. generuję jpga ale niżej będzie inny obrazek dlatego chcę, żeby ten wyższy miał gdzieniegdzie przezroczystość. jeśli funkcja, której używam jest przeznaczona do gifów/pngów to może inaczej to zrobić?
<?
header('Content-type: image/jpeg');
$im = imagecreatefromjpeg('b.jpg');
$src_img = $im;
$angle = -7;
$bicubic=false;
// convert degrees to radians
$angle = $angle + 180;
$angle = deg2rad($angle);
$src_x = imagesx($src_img);
$src_y = imagesy($src_img);
$center_x = floor($src_x/2
); $center_y = floor($src_y/2
);
$cosangle = cos($angle);
$sinangle = sin($angle);
foreach($corners as $key=>$value) {
$value[0]-=$center_x; //Translate coords to center for rotation
$value[1]-=$center_y;
$temp[0]=$value[0]*$cosangle+$value[1]*$sinangle;
$temp[1]=$value[1]*$cosangle-$value[0]*$sinangle;
$corners[$key]=$temp;
}
$min_x=1000000000000000;
$max_x=-1000000000000000;
$min_y=1000000000000000;
$max_y=-1000000000000000;
foreach($corners as $key => $value) {
if($value[0]<$min_x)
$min_x=$value[0];
if($value[0]>$max_x)
$max_x=$value[0];
if($value[1]<$min_y)
$min_y=$value[1];
if($value[1]>$max_y)
$max_y=$value[1];
}
$rotate_width=round($max_x-$min_x); $rotate_height=round($max_y-$min_y);
$rotate=imagecreatetruecolor($rotate_width,$rotate_height);
imagealphablending($rotate, false);
imagesavealpha($rotate, true);
//Reset center to center of our image
$newcenter_x = ($rotate_width)/2;
$newcenter_y = ($rotate_height)/2;
for ($y = 0; $y < ($rotate_height); $y++) {
for ($x = 0; $x < ($rotate_width); $x++) {
// rotate...
$old_x = round((($newcenter_x-$x) * $cosangle + ($newcenter_y-$y) * $sinangle)) + $center_x;
$old_y = round((($newcenter_y-$y) * $cosangle - ($newcenter_x-$x) * $sinangle)) + $center_y;
if ( $old_x >= 0 && $old_x < $src_x
&& $old_y >= 0 && $old_y < $src_y ) {
$color = imagecolorat($src_img, $old_x, $old_y);
//$color = imagecolorset($src_img, 247, 247, 173);
} else {
// this line sets the background colour
$color = imagecolorallocatealpha($src_img, 247, 247, 173, 127);
}
imagesetpixel($rotate, $x, $y, $color);
}
}
$im = $rotate;
$trans = imagecolorallocate($im, 247,247,173);
imagecolortransparent($im,$trans);
?>