Find all image files with a resolution wider then a given width.
#!/bin/sh | |
# findlargefiles - Find all image files with a resolution wider then a given width. | |
# Supports Joomla versions 1.0 - 3.3 | |
# | |
# Copyright 2014 Rene Kreijveld - email@renekreijveld.nl | |
# | |
# This program is free software; you may redistribute it and/or modify it. | |
# Define general variables | |
JOOMLACONF=./configuration.php | |
STARTPATH=./images | |
MINWIDTH=640 | |
MINHEIGHT=640 | |
# Check if configuration.php exists. | |
if [ ! -e ${JOOMLACONF} ] | |
then | |
echo "File configuration.php not found. Are you at the root of the site?" | |
exit 1 | |
fi | |
cd ${STARTPATH} | |
# Find all image files | |
find . -print0 -type f | while read -d $'\0' file | |
do | |
# Ff file is a jpg/gif/png then proceed | |
if echo "$file" | egrep -q ".jpg|.jpeg|.gif|.png"; then | |
id=`identify "$file"` | |
# Get image width and height | |
if echo "$id" | egrep -q "JPEG"; then | |
width=`echo $id | sed 's/JPEG/#/g' | cut -d "#" -f 2 | cut -d " " -f 2 | cut -d x -f 1` | |
height=`echo $id | sed 's/JPEG/#/g' | cut -d "#" -f 2 | cut -d " " -f 2 | cut -d x -f 2` | |
fi | |
if echo "$id" | egrep -q "PNG"; then | |
width=`echo $id | sed 's/PNG/#/g' | cut -d "#" -f 2 | cut -d " " -f 2 | cut -d x -f 1` | |
height=`echo $id | sed 's/PNG/#/g' | cut -d "#" -f 2 | cut -d " " -f 2 | cut -d x -f 2` | |
fi | |
if echo "$id" | egrep -q "GIF"; then | |
width=`echo $id | sed 's/GIF/#/g' | cut -d "#" -f 2 | cut -d " " -f 2 | cut -d x -f 1` | |
height=`echo $id | sed 's/GIF/#/g' | cut -d "#" -f 2 | cut -d " " -f 2 | cut -d x -f 2` | |
fi | |
# Test if width larget then given width | |
if [ $width -gt ${MINWIDTH} ]; then | |
echo $file: width $width, larger than ${MINWIDTH} | |
fi | |
#if [ $height -gt ${MINHEIGHT} ]; then | |
# echo $file: height $height, larger than ${MINHEIGHT} | |
#fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment