A fail-safe way to prevent GD image library from running out of memory? (PHP)

前端 未结 6 1481
礼貌的吻别
礼貌的吻别 2020-12-31 20:01

Is there a way to prevent the PHP GD image library from running out of memory? If too large an image is uploaded, GD tends to run out of memory, terminating the script. I\'d

6条回答
  •  灰色年华
    2020-12-31 20:50

    Do some tests to check how much memory each gd function need.

    • imagecreatetruecolor seems to need width*height*5 bytes.

    • imagepng seems to need width*height*4 bytes.

提交回复
热议问题