FIX: Handle image decoding failure in composer image optimization (PR #13555)

There are some hard limits in browser Canvas implementations, that will throw a runtime exception when crossed. Since those limits are platform dependent, the best we can do is catch it and back off from trying to optimize a problematic file.

For example, a 60MB PNG can be processed fine by Chrome but Firefox will fail trying to extract the ImageData from the CanvasRenderingContext2D with NS_ERROR_FAILURE.

Also cleans up the media-optimization-utils and add post-resize size logs

GitHub