silverstripe/silverstripe-framework — pull request #2753 by kinglozzer (2014-01-02 16:47:03+00:00)
Title: API: Prevent large images from repeatedly crashing PHP on resize

DO NOT MERGE.

Submitting this PR early for comments / critique before I delve too deep in this.

This is a (late) follow up to the discussion [here](https://groups.google.com/forum/#!searchin/silverstripe-dev/image/silverstripe-dev/B57a3KYeAVQ/fUjsQQnfEPAJ) about GD crashing when attempting to open large or high DPI images.

This is far from an ideal / polished solution (the Google Group discussion involved ideas around “image unavailable” icons in the CMS) but is more a temporary fix and hopefully the discussion will pave the way for better handling of these sort of issues.

Implements the same fix that #2569 was going to. Also uses the same method as that PR for checking available memory, though it’s different to the [method Ingo suggested](http://php.net/manual/en/function.imagecreatefromjpeg.php#64155). I’m not really sure which is more robust, the method in the php.net comments doesn’t take into account that bits and channels aren’t always present in the image info.

Marked as an API change as I’ve added a few methods to the `Image_Backend` interface.

All comments welcome.