PHP image crop outside image bounds gives black bar

Viewed 20

When I use this to crop the image I get a horrible black bar at the top:

$image_new = imagecrop($image_source,['x'=>235,'y'=>-50,'width'=>1650,'height'=>1650]);

I also tried this (same result):

imagecopy($image_new,$image_source, 0, 0, 235, -50, 1650, 1650);

Obviously the -50 is sampling from outside the canvas.

It seems when you crop in PHP GDimage outside of the bounds...you get black bars

How do I solve this problem? I need to get alpha instead.

0 Answers
Related