Schlagwort: images

Kleines Shell Script zum Auffinden von Bildern mit gewisser Größe

Voraussetzungen:

  • Bash
  • find, awk
  • identify von ImageMagick oder GraphicsMagick
#!/bin/bash

MIN_WIDTH=240
MIN_HEIGHT=200

# internal field separator, https://bash.cyberciti.biz/guide/$IFS
# changed to make file names with spaces work
OIFS="$IFS"
IFS=$'\n'
# find all files with type image
for image in `find . -type f -exec file {} \; | awk -F: '{if ($2 ~/image/) print $1}'`; do
# get image dimensions (width/height), ignore errors
       width_and_height=`identify -format '%w %h' "$image" 2>/dev/null`
       if test -n "$width_and_height"; then
               width=`echo "$width_and_height" | awk '{print $1}'`
               height=`echo "$width_and_height" | awk '{print $2}'`

               if [ "$width" -lt $MIN_WIDTH ] || [ "$height" -lt $MIN_HEIGHT ]; then
                       echo "wrong dimensions: $image $width x $height"
               fi
       else
               echo "unable to get image dimensions for $image"
       fi
done
IFS="$OIFS"
Anfrage