API: Prevent large images from repeatedly crashing PHP on resize