How can I tell if a JPEG is unnecessarily large for web use?

Asked 1/9/2019

1 views

2 answers

0

I need to process a large library of JPEGs for website display and want to identify images that could be recompressed to smaller file sizes without visibly hurting quality. I first considered using a file-size-per-megapixel rule, but I’m not sure that works because different images may compress differently. Is there a better way to decide whether a JPEG is “too big” for its dimensions when preparing images for the web?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

7y ago

2 Answers

31

The size of files compressed with JPEG vary depending on the complexity of the image. Trying the control the file sizes the way you describe will result in highly variable perceived image quality.

Consider the following options instead:

  • The good-enough approach. Use a quality setting that you find acceptable, like 75. Compare the size of the result with the original image, and keep the smaller file. See What quality to choose when converting to JPG?

  • Use a JPEG minimizer, like JPEGmini or jpeg-recompress from jpeg-archive. They are essentially designed to do what you seem to be trying to do, but with more awareness of JPEG algorithm internals.

  • Generate thumbnails of various sizes, as Nathancahill suggests, from a web-developer perspective.

Originally by user75526. Source · Licensed CC BY-SA 4.0

user75526

7y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

A fixed “KB per megapixel” rule is not a reliable way to judge JPEGs. File size depends on three things: image dimensions, JPEG compression quality, and image content/detail. A flat white image and a detailed forest at the same pixel size can differ greatly in file size even with the same JPEG settings.

For web use, a better workflow is:

  1. Decide the actual display sizes you need on the site, including any higher-resolution (@2x) versions.
  2. Generate resized web versions from the originals rather than judging only by current file size.
  3. Use a JPEG quality setting that looks acceptable to you (often a moderate setting such as around 75 is used as a starting point).
  4. Compare the recompressed file to the original and keep the smaller one if visual quality is still acceptable.

If you want to automate this efficiently, tools made for JPEG optimization—such as JPEGmini or jpeg-recompress/jpeg-archive—are designed for this kind of task and can outperform a simple file-size heuristic.

So: don’t classify images as “too big” by dimensions alone; optimize based on intended display size and acceptable visual quality.

UniqueBot

AI

7y ago

Your Answer