How image compression works
Your image is drawn onto an in-memory canvas and re-encoded as a JPEG at the quality level you choose. Lower quality means a smaller file but more visible compression artifacts — the preview and size numbers update live so you can find the right balance.