Req #77989 [Opn->Nab]: Enhance imagebmp function if it's failed to output image

From: Date: Wed, 08 May 2019 06:27:47 +0000
Subject: Req #77989 [Opn->Nab]: Enhance imagebmp function if it's failed to output image
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220766@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77989&edit=1 ID: 77989 Updated by: requinix@php.net Reported by: peter279k at gmail dot com Summary: Enhance imagebmp function if it's failed to output image -Status: Open +Status: Not a bug Type: Feature/Change Request Package: Output Control Operating System: Ubuntu 18.04 LTS PHP Version: 7.3.5 Block user comment: N Private report: N New Comment: https://www.php.net/manual/en/functions.internal.php > Note: If the parameters given to a function are not what it expects, such as passing an array > where a string is > expected, the return value of the function is undefined. In this case it will likely return > NULL but this is just > a convention, and cannot be relied upon. imagecreatefrombmp() failed. imagebmp() is returning NULL because the $im argument is invalid. Previous Comments: ------------------------------------------------------------------------ [2019-05-08 06:20:29] peter279k at gmail dot com Test script: --------------- <?php $im = imagecreatefrombmp('./php.bmp'); // Save the image var_dump(imagebmp($im, './php.bmp')); // Free up memory imagedestroy($im); Expected result: ---------------- PHP Warning: imagecreatefrombmp(): './php.bmp' is not a valid BMP file in /root/bmp.php on line 3 PHP Warning: imagebmp() expects parameter 1 to be resource, bool given in /root/bmp.php on line 6 bool(false) PHP Warning: imagedestroy() expects parameter 1 to be resource, bool given in /root/bmp.php on line 9 Actual result: -------------- An error as follows: PHP Warning: imagecreatefrombmp(): './php.bmp' is not a valid BMP file in /root/bmp.php on line 3 PHP Warning: imagebmp() expects parameter 1 to be resource, bool given in /root/bmp.php on line 6 NULL PHP Warning: imagedestroy() expects parameter 1 to be resource, bool given in /root/bmp.php on line 9 ------------------------------------------------------------------------ [2019-05-08 04:18:25] requinix@php.net Oops, I meant Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with , is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2019-05-08 04:18:00] requinix@php.net Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PHP. ------------------------------------------------------------------------ [2019-05-08 03:45:43] peter279k at gmail dot com Description: ------------ According to the caution message in imagebmp function usage https://php.net/manual/en/function.imagebmp.php, it looks like the imagebmp should return false if it's failed to output the image. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77989&edit=1

« previous php.bugs (#220766) next »