I use imagecreatefromjpeg on a shared host, so if the image is large, then imagecreatefromjpeg will give me a "memory error" and exit the script.
Anyway, to avoid memmory error and just let imagecreatefromjpeg crash (Return false) instead of ending script?
Try to determine the image size first: http://uk3.php.net/function.getimagesize I believe that imagecreatefromjpeg will fall if the image is larger than 3000 pixels in any size.
imagecreatefromjpeg script, , , . : = * 3
. 1000 x 2000,
1000 x 2000
memory required= ((1000 * 2000) * 3)=600000 bytes =5.72205MB
5242880 (5 ), imagecreatefromjpeg()
if($memory_required < 5242880) { imagecreatefromjpeg(); // continue with your image related operations } else { //handle error message, perhaps show such message as "provide image is too big" }
PHP PHP (, )
. :
GD? ()
- -
@ - ?
:
$x=@imagecreatefromjpeg .......
see also how to suppress errors in php: http://us3.php.net/manual/en/language.operators.errorcontrol.php
Just attach your function to the if statements, indicating that it is redirected when the function fails.
i.e. if (! imagecreatefromjpeg) {// redirects commands here};
Source: https://habr.com/ru/post/1717071/More articles:Get the maximum viewing distance from the current zoom level using the Google Maps API - javascriptHow to write a large amount of data in a tarfile in python without using a temporary file - pythonReferring to the identifier of the component, output the variable - flexPHP Active Directory Authentication with Kerberos - authenticationApplet-server communication, how can I do this? - javaHow to decode HTML-encoded text in MS Access - htmlWork with CSV - SQLite against the shell (join / paste / cut) - shellSetting up a SQL table query - sqlHow to use StandardAnalyzer with TermQuery? - pythonWho should perform code verification? - code-reviewAll Articles