Comments on: How to Optimize and Compress JPEG or PNG Images in Linux Commandline https://www.tecmint.com/optimize-and-compress-jpeg-or-png-batch-images-linux-commandline/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Fri, 14 Jul 2023 03:42:43 +0000 hourly 1 By: Stephen Ajulu https://www.tecmint.com/optimize-and-compress-jpeg-or-png-batch-images-linux-commandline/comment-page-2/#comment-1622895 Wed, 27 Oct 2021 06:03:34 +0000 http://www.tecmint.com/?p=18312#comment-1622895 In reply to Aamnah.

Hi, how are you? Thanks so much for this. Made a bash script to run on my site’s image folder and it works well. Working on creating a cronjob for automation. Now I have a question. How can I do the same with GIFs, WEBP, and SVGs?

]]>
By: Roman H. https://www.tecmint.com/optimize-and-compress-jpeg-or-png-batch-images-linux-commandline/comment-page-2/#comment-1340448 Tue, 23 Jun 2020 11:14:44 +0000 http://www.tecmint.com/?p=18312#comment-1340448 In reply to Jonathan.

jpegoptim dir/**/*.jpg

]]>
By: Euph0ria https://www.tecmint.com/optimize-and-compress-jpeg-or-png-batch-images-linux-commandline/comment-page-2/#comment-1318308 Sun, 23 Feb 2020 03:21:40 +0000 http://www.tecmint.com/?p=18312#comment-1318308 Does either of these optimization tools retain metadata embedded in the image? (such as Exif, etc)

]]>
By: xekon https://www.tecmint.com/optimize-and-compress-jpeg-or-png-batch-images-linux-commandline/comment-page-2/#comment-1313040 Wed, 22 Jan 2020 02:05:37 +0000 http://www.tecmint.com/?p=18312#comment-1313040 In reply to Bruce Bates.

I actually experienced the opposite, optipng does great, if you try to use ffmpeg the file gets 10x larger.

Take a file, for example, image7.png and do the following:

# optipng -o7 -zm1-9 -strip all image7.png -out image7-optipng.png
# ffmpeg -i image7.png image7-ffmpeg.png
# convert image7.png -define png:compression-level=9 image7-magik.png
# pngcrush image7.png image7-crush.png
]]>
By: Julian https://www.tecmint.com/optimize-and-compress-jpeg-or-png-batch-images-linux-commandline/comment-page-2/#comment-1292201 Mon, 18 Nov 2019 22:12:24 +0000 http://www.tecmint.com/?p=18312#comment-1292201 In reply to Aamnah.

Hi,

this usage of `find` in conjunction with `jpegoptim` (and possibly also with `optipng`) will call the `jpegoptim` command for every file `find` matches.

In case anyone is looking for processing all matching files in a single run, try the following:

`find path/to/images/ -regex ".*\.\(jpg\|jpeg\)" -exec jpegoptim {} +`

Note the `+` at the end of the `exec` command, which leads to `exec` finally being called with all matching files.

Source: https://www.booleanworld.com/guide-linux-find-command/ (right above “Executing commands on directories”)

]]>