Photos and graphics compress differently
JPG works well for continuous-tone photos, while sharp text, icons and flat-color edges can reveal compression artifacts. PNG preserves those edges and transparency, but photo-heavy PNG files can become much larger.
Is WebP always the answer?
WebP is often efficient for both photos and graphics and supports transparency. It is a strong web format, but check whether the apps and workflows that receive the file support it.
Conversion cannot restore missing detail
Changing an already compressed JPG to PNG may increase file size, but it cannot recover detail lost in the JPG. Converting PNG to JPG can remove transparency and introduce lossy compression.
When the choice is unclear
Export the same image in two formats and compare them at the size people will actually see. A difference visible only at extreme zoom may not matter in the final page or document.
Worked check: compare the output
Example: Converting a 2 MB JPG photo to PNG does not restore lost sharpness. Lossless PNG preserves the pixels present at conversion time. Compare both files at 100% zoom.
Save the output and inspect it alongside your original. Results depend on the document and destination software.