class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
The error occurs because when the class crops, with negative margins, it creates up extra space, which by default is black. PHP image_file() function fills that area, but spills on the picture itself if it contains a contiguous black area.
To solve it, change the following into:
// fill in from the edge of the negative margin
if ($ct < 0) imagefill($tmp, round($this->image_dst_x / 2), 1, $fill);
if ($cr < 0) imagefill($tmp, $this->image_dst_x - 1, round($this->image_dst_y / 2), $fill);
if ($cb < 0) imagefill($tmp, round($this->image_dst_x / 2), $this->image_dst_y - 1, $fill);
if ($cl < 0) imagefill($tmp, 1, round($this->image_dst_y / 2), $fill);
As for the images not being created quickly enough, it is strange. When the class dumps the image, it does so, then only the script continues. So when the page with the link to the image is sent to the browser, the image has been indeed created. Maybe your live server uses a filer, and the files need a little bit of time to synchronise.
The error occurs because when the class crops, with negative margins, it creates up extra space, which by default is black. PHP image_file() function fills that area, but spills on the picture itself if it contains a contiguous black area.
To solve it, change the following into:
to
This will be added in the next release.
As for the images not being created quickly enough, it is strange. When the class dumps the image, it does so, then only the script continues. So when the page with the link to the image is sent to the browser, the image has been indeed created. Maybe your live server uses a filer, and the files need a little bit of time to synchronise.
(edit: implemented a better fix)