A simple bash script to:
- Remove all metadata from images
- Reduce file size without quality loss
- Add
-processedsuffix to filenames (optional) - Move processed files to a
processed/folder
- Supports JPG, JPEG, PNG, GIF, BMP, TIFF, WebP
- Uses
exiftoolto strip metadata - Uses
jpegoptimfor JPEG optimization - Uses
optipngfor PNG optimization - Uses
convert(ImageMagick) for other formats - Displays file size savings
- Optional
--keep-nameflag to preserve original filenames instead of appending-processed
-
Download the script to your preferred location, e.g.:
curl -O https://example.com/image_process.sh
-
Make it executable:
chmod +x image_process.sh
-
Move to a directory in your PATH:
sudo mv image_process.sh /usr/local/bin/image_process
If you prefer a user-local installation without sudo, move the script to ~/.local/bin (ensure this directory is in your PATH):
mkdir -p ~/.local/bin
mv image_process.sh ~/.local/bin/image_process
chmod +x ~/.local/bin/image_process
export PATH="$HOME/.local/bin:$PATH" # Add to ~/.bashrc or ~/.zshrcInstall required tools:
# Debian/Ubuntu
sudo apt install libimage-exiftool-perl jpegoptim optipng imagemagick
# RHEL/Fedora
sudo dnf install perl-Image-ExifTool jpegoptim optipng ImageMagick
# Arch Linux
sudo pacman -S perl-image-exiftool jpegoptim optipng imagemagickRun the script in any directory containing images:
process_images [--keep-name]-k, --keep-name
: Preserve the original filenames in the processed/ folder instead of appending -processed.
- By default, files are renamed to
originalname-processed.extand saved inprocessed/. - With
--keep-name, files retain their original names inprocessed/. - Example:
- Default:
IMG1234.jpg→processed/IMG1234-processed.jpg - Keep name:
IMG1234.jpg→processed/IMG1234.jpg
- Default:
Enjoy optimized, metadata-free images!