Showing posts with label ImageMagic. Show all posts
Showing posts with label ImageMagic. Show all posts

24 October, 2008

Eclipse icons

How to extract icons from Eclipse


I've created it in few steps:

  1. Downloaded and unzipped eclipse

  2. Extracted all images from eclipse directories, subdirectories, zips and jars*

  3. Filtered only unique files*

  4. Sorted images by dimension (16x16, 24x24, 32x32, etc.)*

  5. Removed large images (that not look like icon)

  6. Created html pages (via PHP script)

* Via my shell scripts.

This is one script from this project:
#!/bin/bash

#Find and copy only unique files (with same size and checksums) from $SOURCE directory to $OUTPUT.

SOURCE=output
OUTPUT=images

rm -rf $OUTPUT
mkdir -p $OUTPUT

uniqProcess() {

echo >xqx_unique.idx
while read; do
echo -ne \\r$REPLY
echo $REPLY $(stat -c%s $REPLY)+$(md5sum $REPLY|cut -f 1 -d ' ')+$(cksum $REPLY|cut -f 1 -d ' ')>>xqx_unique.idx
done
sort -k 2 xqx_unique.idx|uniq -f 1|cut -f 1 -d ' '|xargs -I '{}' cp '{}' $OUTPUT
}

find $SOURCE -type f |uniqProcess

22 August, 2008

HowTo find inconsistency between image format and file extension

Sometimes image files have inconsistency between format and extension.
For example: .jpeg file saved as .png file.

I wrote simple script in order to find such files:
#!/bin/bash

process() {
while read; do
diff=`identify -format "%m %e" "$REPLY" | tr [A-Z] [a-z] | egrep -v "^(png png|gif gif|jpg jpg|jpeg jpg|jpeg jpeg)"`
test -n "$diff" && echo $diff $REPLY
done
}

find -type f -iregex ".*\.\(png\|gif\|jpg\|jpeg\)$" | process

It outputs information about real file format, file extension and filename in case of
difference between format and extension.
Like this:

jpeg png images/rating_0.png
png gif images/left.gif
gif png images/border_tr.png