Shahab Ali
asked on
Transparency not completely removed imagerotate
Hi, I am trying to rotate an image using php image rotate and my goal is to retain the transparency of the image after the rotation. I tried the following method according to a solution posted by techtonik but it doesn't completely make the image transparent as the original image. There are still some parts with the color. I have added an image which shows my results. The green color can be seen in the square image.
$imagew = imagecreatefrompng('new_im age.png')
$stubColor = imagecolorallocate($imagew , 0, 255, 0);
imagefill($imagew, 0, 0, $stubColor);
$imgcolors = imagecolorstotal($imagew);
$rotimg = imagerotate($imagew, 25, $stubColor);
imagedestroy($imagew);
imagetruecolortopalette($r otimg, false, $imgcolors);
imagecolortransparent($rot img, imagecolorat($imagew, 0, 0));
for ($levels = 0; $levels < 10; $levels++) {
$stubColor = imagecolorclosest($rotimg, 128, 100, 100);
imagecolordeallocate($roti mg, $stubColor);
imagecolorallocate($rotimg , 0, 0, 0);
}
imagepng($rotimg, 'my_image.png');
imagedestroy($rotimg);
$imagew = imagecreatefrompng('my_ima ge.png');
$imgcolors = imagecolorstotal($imagew);
imagecolortransparent($ima gew, imagecolorat($imagew, 0, 0));
imagepng('my_image.png1');
$imagew = imagecreatefrompng('new_im
$stubColor = imagecolorallocate($imagew
imagefill($imagew, 0, 0, $stubColor);
$imgcolors = imagecolorstotal($imagew);
$rotimg = imagerotate($imagew, 25, $stubColor);
imagedestroy($imagew);
imagetruecolortopalette($r
imagecolortransparent($rot
for ($levels = 0; $levels < 10; $levels++) {
$stubColor = imagecolorclosest($rotimg,
imagecolordeallocate($roti
imagecolorallocate($rotimg
}
imagepng($rotimg, 'my_image.png');
imagedestroy($rotimg);
$imagew = imagecreatefrompng('my_ima
$imgcolors = imagecolorstotal($imagew);
imagecolortransparent($ima
imagepng('my_image.png1');
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not sure - maybe post a new question and open it up to some other experts.
ASKER
Okay thanks
ASKER