Notice on imagecolorat()
geri777 opened this issue · 3 comments
geri777 commented
Notice: imagecolorat(): 45,2848 is out of bounds in class.upload.php on line 4902
The image has a height of 2848 pixels!
original:
$rgba = imagecolorat($image_dst, $x, $y);
fixed:
$rgba = imagecolorat($image_dst, $x, $y == 0 ? 0 : $y - 1);
The size seems to be a null-based index.
https://stackoverflow.com/questions/38340662/php-get-color-at-last-pixels-of-image-error
verot commented
Thank you for reporting the issue. Can you provide me with a test case?
Besides, is the problem affecting all calls to imagecolorat()
or only this one call?
geri777 commented
Hi Verot, thank you for the fast reply.
This is my test case:
$handle = new \Verot\Upload\Upload($_FILES['image']);
if ($handle->uploaded){
$handle->file_new_name_body = 'a_unique_string';
$handle->image_convert = 'jpg';
$maxWidth = 1900;
$handle->image_resize = true;
$handle->image_x = $maxWidth;
$ratio = $maxWidth / $handle->image_src_x;
$handle->image_y = $handle->image_src_y * $ratio;
$handle->Process('./uploads/');
if ($handle->processed) {
echo("success");
}
}
I did not dig into this - no idea why it uses the imagecolorat() function, I am just resizing.
I just did the quickfix to get rid of the notice.
Thank you for your great support and all your work on this lib.