Date
Jul. 19th, 2024
 
2024年 6月 14日

Post: Script for Optimizing Images

Script for Optimizing Images

Published 14:02 Feb 13, 2023.

Created by @ezra. Categorized in #UNIX/Linux, and tagged as #Arch Linux, #UNIX/Linux, #Ubuntu Linux.

Source format: Markdown

Table of Content

Sample Script

Optimizing images is easy with this script! Img-optimizer + ImageMagicK leverages multiple CLI tools to give the best results.

#!/bin/bash
# Dependencies
# - img-optimize - https://virtubox.github.io/img-optimize/
# - imagemagick
# - jpegoptim
# - optipng

for file in *.png; do convert "$file" -verbose -resize 600\> "$file"; done
img-optimize --std --path "$(pwd)"

Dependencies

  • imagemagick
  • opting
  • jpegoptim

Debian Command

sudo apt install jpegoptim optipng imagemagick webp -y
git clone https://github.com/VirtuBox/img-optimize.git $HOME/.img-optimize
sudo ln -s $HOME/.img-optimize/optimize.sh /usr/local/bin/img-optimize
sudo chmod +x /usr/local/bin/img-optimize

Arch Command

yay -S jpegoptim opting imagemagick webp -y
git clone https://github.com/VirtuBox/img-optimize.git $HOME/.img-optimize
sudo ln -s $HOME/.img-optimize/optimize.sh /usr/local/bin/img-optimize
sudo chmod +x /usr/local/bin/img-optimize

Custom Script

#!/bin/bash
# Dependancies
# - img-optimize - https://virtubox.github.io/img-optimize/
# - imagemagick
# - jpegoptim
# - optipng

FOLDER="/home/ezra/ecs/website/content/images"

# max width
WIDTH=800

# max height
HEIGHT=600

#resize png or jpg to either height or width, keeps proportions using imagemagick
find ${FOLDER} -iname '*.jpg' -o -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;
img-optimize --std --path ${FOLDER}
Pinned Message
HOTODOGO
I'm looking for a SOFTWARE PROJECT DIRECTOR / SOFTWARE R&D DIRECTOR position in a fresh and dynamic company. I would like to gain the right experience and extend my skills while working in great teams and big projects.
Feel free to contact me.
For more information, please view online résumé or download PDF
本人正在寻求任职 软件项目经理 / 软件技术经理 岗位的机会, 希望加⼊某个新鲜⽽充满活⼒的公司。
如有意向请随时 与我联系
更多信息请 查阅在线简历下载 PDF