Showing posts with label RegExp. Show all posts
Showing posts with label RegExp. Show all posts

24 February, 2009

PHP-reference

I'm happy to introduce one more my project: PHP-reference.

This is the interactive engine for PHP documentation: the client side is implemented with ExtJS/JavaScript, and PHP for server side.
It uses original PHP documentation (processed via regexps and colored with CSS styles) as a data source.

I've tried to create it as usable as possible... any requests, ideas welcome!

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