react-image-compressor icon indicating copy to clipboard operation
react-image-compressor copied to clipboard

Often won't display the image

Open ticknerr opened this issue 6 years ago • 3 comments

Hi, nice and simple, I'm just adapting this and combining it with Material UI .. but even in your demo it won't display images over 3MB. Any quick ideas why? I'll see if I can figure it out but if you know please sing out!

ticknerr avatar Nov 22 '18 00:11 ticknerr

actually it's a little more strange, it doesn't show many images, but as soon as you start to reduce the Scale, the image will appear. You can see it do the same in your demo :)

ticknerr avatar Nov 22 '18 00:11 ticknerr

The fix seems to be this:

After you create the img in the _drawImage method, with let img = new Image() img.src = imgUrl

Then place the rest of the code in this method inside the following closure: img.onload = () => { here }

ticknerr avatar Nov 22 '18 04:11 ticknerr

Please share your file @ticknerr

SohaibIbneAli avatar Jun 21 '20 19:06 SohaibIbneAli