Simple batch resize & watermark with imagemagick

Fast & simple batch image handling with imagemagick, from the command line.

Last year I finally decided to end up with Microsoft (Windows 7 is so far from my attitude), therefore Ubuntu made it into my life. Fortunately, the most of the software I used was already cross-platform, the most hard part was with DJ software ( Mixxx with version 1.8 is OK, but before… ), with graphical editing and something instead of XnView.

Yes, there is XnView MP and nconvert, but both of them is full of bugs. The only reasonable program to use is ImageMagick, but is has an extremely awful documentation, which lacks vital examples.

Finally, I figured out the script I needed for resizing and watermaking images:


# change directory to the desired one
cd $1

# create resized dir
# warning! if exists, the pictures will be overwritten!
mkdir resized

# look up files with extensions
for fname in *.*; do

  # this is the resize and slightly sharpen part
  echo "resizing $fname"
  mogrify -sharpen 1 -quality 96% -write "./resized/$fname" -resize 540x540 "$fname"

  # this is the watermarking part
  echo "watermarking $fname"
  composite -compose atop -gravity SouthEast "/path/to/watermark/image" "./resized/$fname" "./resized/$fname"


And that’s all.


bash desired/folder/path/with/images/

Encourage creation!

If this entry helped you, or you simply liked it, leave a tip via
Monzo (only in the UK or via Google Pay) or Paypal