Hey
I've just made a new image class so I can create images easily (thumbnails, avatars etc). Ive made it so I can choose it to have transparent edges or not (so as to keep all images the same size).
However, sometimes, only half the edges are transparent.
the script is here:
http://munkydesigns.co.uk/Scripts/Image/Index.php - to upload your own image and see
http://munkydesigns.co.uk/Scripts/Image/Images - to see the image uploaded
some code:
$maxW/H are the max dimensions of the image.
$dW/H are the default values, that change depending on the aspect ratio
$rD/G/D are the colour values you can set, which are 0,0,0
$widthO/heightO are the original dimensions of the uploaded image.
everything resizes fine, just sometimes (mainly on the portait images) one edge is black (not transparent)
does anyone have any ideas as to what i'm doing wrong?
I've just made a new image class so I can create images easily (thumbnails, avatars etc). Ive made it so I can choose it to have transparent edges or not (so as to keep all images the same size).
However, sometimes, only half the edges are transparent.
the script is here:
http://munkydesigns.co.uk/Scripts/Image/Index.php - to upload your own image and see
http://munkydesigns.co.uk/Scripts/Image/Images - to see the image uploaded
some code:
PHP:
//create placement image
$imageP = ImageCreateTrueColor($maxW, $maxH);
if ($alpha == 1){
//if alpha is selected
ImageSaveAlpha($imageP, true);
$backColour = ImageColorAllocateAlpha($imageP, $rD, $gD, $bD, 127);
}else{
$backColour = ImageColorAllocate($imageP, $rD, $gD, $bD);
}
ImageCopyResampled($imageP, $image, ($maxW - $dW)/2, ($maxH - $dH)/2, 0, 0, $dW, $dH, $widthO, $heightO);
ImageFill($imageP, 0, 0, $backColour);
$maxW/H are the max dimensions of the image.
$dW/H are the default values, that change depending on the aspect ratio
$rD/G/D are the colour values you can set, which are 0,0,0
$widthO/heightO are the original dimensions of the uploaded image.
everything resizes fine, just sometimes (mainly on the portait images) one edge is black (not transparent)
does anyone have any ideas as to what i'm doing wrong?







