A preview can take up the right space on the page and still look blurry. For a canvas that displays at 360 by 240 CSS pixels on a screen with a device pixel ratio of 2, use a backing store of 720 by 480 pixels. Keep the CSS size at 360 by 240.
Multi...
A button below a preview should stay put while the image loads. Reserve the space for the image before the browser opens the file.
If you know a published image's dimensions, set the width and height attributes on the image element. Let CSS scale it...
Select an image and clear the file picker before the preview appears. If the image shows up afterward, a decode from the old selection is still updating the interface. Invalidate that pending result when the picker is cleared.
Try again after the pr...
A user picks photo A, then picks B while A is decoding. If B finishes first, a late result from A can replace the correct preview. Give each selection a number and check it just before updating the display.
Have the decoder return a detached image e...
Give a file-size rejection its own result in an image-preview flow. You can check the selected file's byte budget before starting decoding, then report a size problem without calling it an image-decoding failure.
MDN documents File.size, inherited f...
A JPEG export can leave a soft fringe around colored text even when the image keeps its original dimensions. Before pushing the quality slider higher, check whether the encoder is reducing the resolution of the color channels. That process is called ...