A few scripts to help convert/optimize images.
This is a set of image optimizing tools/helpers. Nothing fancy or advanced, but just to make it easier to use. 2 scripts are to create/convert files, and the other ones to optimize images.
I used a GUI tool before, but decided to move over to using these scripts instead. Much easier and more convinient, and I can use the same set of scripts in both GNU/Linux and macOS. You can use them as they are, or perhaps together with other scripts - as helpers.
Install the files to /usr/local/bin, or to any other location. Just make sure it's added to PATH.
I use /usr/local/xbin for these scripts, so...
$ cd /path/to/imageOpt/files
$ sudo install -v -m755 -o0 -g0 mk* *opt /usr/local/xbinYou'll need to have these programs installed:
convert(ImageMagick), ormagick(ImageMagick v7),jpegoptimoptipnggifsicle
Each scripts will abort if any dependecies are missing.
Refer to your package manager (pacman, dnf, apt, port, etc), or compile from source.
Both are using ImageMagick (magick(IM7) or convert(IM6)), and sips(macOS) to create the files.
$ mkjpg -h
# Usage:
# mkjpg [ % ] file.png Default is 100 (%)
# mkjpg 60 file.png 60%
# mkjpg **/{more,files}.png Mulltiple images
# mkjpg -h Show help
$ mkthumb -h
# Usage:
# mkthumb file.jpg Result: file_250px.jpg
# mkthumb 400 file.jpg Result: file_400px.jpg
# mkthumb **/{foo,bar}.jpg Multiple images
# mkthumb -h Show helpjpgopt is using jpegoptim and mkjpg (above). Use 1 or more files, or even the double star ** to recursively run it from where you're at.
$ jpgopt -h
# Usage:
# jpgopt [ % ] file.jpg Default is 100 (%)
# jpgopt 60 file.jpg 60% quality
# jpgopt **/{more,files}.jpg More files
# jpgopt -h Show helpThe line used by jpegoptim looks like this:
jpegoptim -m${_q} -ftPv -s "${_img}";You can also run jpgopt on your PNG images, to batch convert->optimize your images in one take. It uses mkjpg for that. That saves some time.
pngopt is using optipng, and works like jpgopt.
$ pngopt -h
# Usage:
# pngopt [-v] <file(s)> 1 or more files
# pngopt -h Show helpThe line used by optipng looks like this:
optipng -strip all -quiet -o7 "${file}" -out "${file}.opt";-o7 is quite a hard setting, it may take some time on larger files.
If the optimized file doesn't get smaller than the original - it'll keep the original instead.
gifopt is using gifsicle. I don't use it that much - just wanted something simular to the 2 ones above.
$ gifopt -h
# Usage:
# gifopt [-v] [-c <int>] <file(s)> 1 or more files
# gifopt -h Show helpThe line used by optipng looks like this:
gifsicle ${C}-O3 "${file}" -o "${file}.opt";- Fork it (https://gitlab.com/iefdev/imageOpt/forks/new)
- Create your feature branch (
git switch -c feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Merge Request