Free Script Friday. I find myself using this script a lot when I need to convert screenshots or images to something that is best for web use.

Yes, I did use AI to help create this Bash script. It require ImageMagick to handle HEIC files and image manipulation.

I like to create scripts like this for repetitive tasks. In my use case, I needed to convert a bunch of images to JPEG format and reduce their size to 80% so that I could use them for the web. I know there are many other ways to do this, but this works for my needs. Can even assign this script and commands to a hotkey and not even type a single thing in the terminal.

Usage: ./batch_image_convert.sh -d ~/Pictures/ -s 80%

Options:
-d <source_dir> Directory containing the images to convert. If omitted, the script uses the current directory (".").

-s <scale> Resize factor, expressed as a percentage (e.g. 25%). Must end with a percent sign. Default is 50%.

The script creates a sub‑folder named "converted" inside the source directory and writes the converted JPEG files there.

https://gist.github.com/teklynk/1be3121af8616b7f682d791d44358429

#linux #bash #code #automation #imagemanipulation #freescriptfriday

Batch image file convert script

Batch image file convert script. GitHub Gist: instantly share code, notes, and snippets.

Gist