DEV Community

Cover image for Using jpegoptim to optimize JPEG images
Onelinerhub
Onelinerhub

Posted on

Using jpegoptim to optimize JPEG images

1. Batch optimize multiple JPG images

jpegoptim --strip-all /dir/*.jpg
Enter fullscreen mode Exit fullscreen mode
  • jpegoptim - tool to optimize JPG images (apt install jpegoptim),
  • --strip-all - removes all meta data from file,
  • /dir/*.jpg - list of images to optimize (files will be overwritten).

Open original or edit on Github.

2. Optimize JPG image

jpegoptim --strip-all img.jpg
Enter fullscreen mode Exit fullscreen mode
  • jpegoptim - tool to optimize JPG images (apt install jpegoptim),
  • --strip-all - removes all meta data from file,
  • img.jpg - input image to be optimized (will be overwritten).

Open original or edit on Github.

3. Optimize JPG image to fit to certain file size

jpegoptim --strip-all -S 100k img.jpg
Enter fullscreen mode Exit fullscreen mode
  • jpegoptim - tool to optimize JPG images (apt install jpegoptim),
  • --strip-all - removes all meta data from file,
  • -S 100k - try to optimize so that final file size is less than 100k,
  • img.jpg - input image to be optimized (will be overwritten).

Open original or edit on Github.

Top comments (0)