gipm-help-2.doap: make schumaml and myself additional maintainers
[gimp-help-2.git] / tools / check_image_resolutions.sh
blob76bd3532c99e8625248b76e56ccb84cd67436dc9
1 #!/bin/sh
3 # check_image_resolutions -- find image files with resolution != 144x144 dpi
4 # Copyright (C) 2009 The GIMP Documentation Team.
5 # License: GPL
8 usage="Usage: ${0##*/} DIR [DIR ...]"
9 programs="find xargs identify awk"
11 die() {
12 exitcode="$1"; shift
13 echo >&2 "$*"
14 exit $exitcode
17 # Check command line arguments
18 if [ -n "$1" ]; then
19 for arg; do
20 test -d "$arg" || die 65 "No such directory: $arg"
21 done
22 else
23 die 64 "$usage"
26 # Check for required programs
27 for prog in $programs; do
28 type $prog >/dev/null 2>&1 || die 69 "Missing program: $prog"
29 done
31 # Start
32 find "$@" -name .git -prune \
33 -o \( -name *.png -o -name *.jpg \) -print | \
34 xargs identify -format "%d/%f %x %y %wx%h\n" | \
35 sort | \
36 awk '
37 BEGIN {
38 n = 0; m = 0;
39 c[0]="|"; c[1]="/"; c[2]="-"; c[3]="\\";
40 print("Checking image files for potential resolution problems...");
42 # Input:
43 # $1 - file name (incl. path)
44 # $2 - x resolution (ok: 56.69, 56.70, 143.*, 144.*)
45 # $3 - x units (e.g. "PixelsPerInch", "Undefined", ...)
46 # $4 - y resolution
47 # $5 - y units
48 # $6 - <width>x<height>
49 # Example:
50 # path/to/image.png 56.69 PixelsPerCentimeter \
51 # 56.69 PixelsPerCentimeter 273x303
52 /./ { ++n }
53 /./ && ($2 !~ /^(56\.|14[34])/ || $4 !~ /^(56|14[34])/) {
54 ++m;
55 if ($2 != $4) {
56 printf("%s (%s): %sx%s [%s]\n", $1, $6, $2, $4, $3)
57 } else {
58 printf("%s (%s): %s [%s]\n", $1, $6, $2, $3)
61 END {
62 printf(" Total: %d Suspects: %d\n", n, m);