General

photo album : imagemagick (part -1)

Cover image description

Quick and dirty way of creating photo album with imagemagick, creating

images with black border as it looks good for all

imagemagick bash
#!/bin/csh
# Create the output directory if it doesn't exist
if (! -d /tmp/foo100) then
mkdir -p /tmp/foo100
endif
# Iterate over each jpg file in the current directory
foreach file ( [0-9]*.jpg )
# Get the width and height of the image
set w = `identify -format "%w" $file`
set h = `identify -format "%h" $file`
# Resize the image based on its orientation and add a black border
if ($w > $h) then
convert $file -thumbnail 500x -bordercolor black -border 1 /tmp/foo100/$file
else
convert $file -thumbnail x500 -bordercolor black -border 1 /tmp/foo100/$file
endif
end

About the Author

Photo of Santanu

Santanu

A nature lover, runner, travel enthusiast, and occasional baker. He dives into web development and cloud technologies, always exploring and building with curiosity.

View all posts →