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

前端 未结 6 1442
礼貌的吻别
礼貌的吻别 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 21:01

    Your best bet is to stop trying to figure out how much ram it will need, and just max it out at the outset - if you have 4 GB available, tell the image script to use between 2 and 4 GB or so, and when the script ends, have it go back to normal, that will cover off all potentially fatal situations. That's the only "Fail-safe" way I can think of anyway ...

提交回复
热议问题