Big-Pat
01-06-2007, 11:59 PM
I'm trying to create a PHP script to take a large image (2.1 Mb) (http://web.originallyorange.com/img/orn-ball.png) and cut it in half and resize it. I don't really know what I'm doing, this is the first time I've used these functions. The problem I'm having is that is has a drop shadow and in the process of keeping the background transparent it gets removed badly and I end up with this:
http://web.originallyorange.com/img/test.png
My code (from tutorials and php manual):
<?php
$width = 58;
$height = 142;
$canvas = imagecreatetruecolor($width,$height);
$piece = imagecreatefrompng('orn-ball.png');
$transp = imagecolorallocate($piece,0,0,0);
imagecolortransparent($canvas,$transp);
$newwidth = 500;
$newheight = 1000;
$cropLeft = 7;
$cropHeight = 7;
imagecopyresized($canvas, $piece, 0,0, $cropLeft, $cropHeight, $width, $height, $newwidth, $newheight);
if (imagepng($canvas,'test.png',90)) {
echo 'Image crop successful';
} else {
echo 'Image crop failed';
}
imagedestroy($canvas);
imagedestroy($piece);
?>
http://web.originallyorange.com/img/test.png
My code (from tutorials and php manual):
<?php
$width = 58;
$height = 142;
$canvas = imagecreatetruecolor($width,$height);
$piece = imagecreatefrompng('orn-ball.png');
$transp = imagecolorallocate($piece,0,0,0);
imagecolortransparent($canvas,$transp);
$newwidth = 500;
$newheight = 1000;
$cropLeft = 7;
$cropHeight = 7;
imagecopyresized($canvas, $piece, 0,0, $cropLeft, $cropHeight, $width, $height, $newwidth, $newheight);
if (imagepng($canvas,'test.png',90)) {
echo 'Image crop successful';
} else {
echo 'Image crop failed';
}
imagedestroy($canvas);
imagedestroy($piece);
?>