Enforce maximum dimensions on image.

From #6470.
The memory error occurs during node save, not when the file is uploaded. Current memory usage wouldn't be accurate. Not that my estimate is any accurate either though.