Bug 1065877: prevent OOMs when editing, picking and sharing large images
(cherry picked from commit 63bc9fa28bf457be57613c55c0c52531e5cb612d)
Merge pull request #24130 from davidflanagan/bug1065877-v1.4

Bug 1065877: prevent OOMs when editing, picking and sharing large images