Dynadot โ€” .com Registration $8.99

Php image only half transparent

Spaceship Spaceship
Watch

Albino

Munky DesignsEstablished Member
Impact
17
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:

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?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
ok, I've half managed to fix it

if I repeat the fill command:

ImageFill($imageP, (($maxW - $dW)/2)+$dW, 0, $backColour);
ImageFill($imageP, 0, (($maxH - $dH)/2)+$dH, $backColour);

so that it specifically targets the edge (by adding one edge and the actual width/height to the co-ordinate), then it seems to correct it.

however, if my image has black touching the edge, that also goes transparent, despite what colour I atempt fill image (with full transparency).

any idea how I can stop this happening?
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back