Ticket #2823: find_invalid_pngs.sh

File find_invalid_pngs.sh, 812 bytes (added by elexis, 9 years ago)

This bash script identifies png files that need to be fixed.

Line 
1#!/bin/bash
2#
3# Identifies all png's in the current directory that contain transparent,colored pixels (which can be problematic).
4# See http://trac.wildfiregames.com/ticket/2823
5#
6# requires 'idenify' of the image magick commandline tool http://www.imagemagick.org/script/identify.php
7# available on debian and ubuntu via sudo apt-get install imagemagick
8
9for filename in *.png; do
10
11 # first grep for histogram lines, like
12 # 26: ( 2, 1, 1, 0) #02010100 srgba(2,1,1,0)
13 # then extract text of each line between the sixth = last comma and the first parenthesis after that
14 for alpha in `identify -verbose $filename | grep 'srgba(' | cut -d ',' -f 7 | cut -d ')' -f 1`; do
15
16 if [ "$alpha" == "0" ]
17 then
18 echo "$filename should be fixed."
19 continue 2;
20 fi
21
22 done
23
24 echo "$filename is ok.";
25done