Mar 3, 2014

Auto resize and optimize images

ImageMagick helps us with command utility: mogrify. It replaces original files, so be careful with this.

The trick is how to search for newly upload files. Here is a solution:

# Create a file to compare (default is now)
# A manual options is: touch --date "2014-01-01"
touch /tmp/fcmp~
# Process newly added files
find -type f -newer /tmp/fcmp~ -name *.jpg -exec mogrify -resize 1200x1200 {} \;

No comments:

Post a Comment

New comment