Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: thumbnails generator

by oko1 (Deacon)
on Apr 20, 2008 at 17:06 UTC ( [id://681803]=note: print w/replies, xml ) Need Help??


in reply to Re: thumbnails generator
in thread thumbnails generator

Now there is a good reason to do it in Perl! I don't think it would be much slower than a script, but that might be worth testing.

#!/bin/bash shopt -s nullglob for image in *.{gif,bmp,jpg,wmf,jpeg,png} do printf "Converting $image\n" bits=(`/usr/bin/identify -format "%h %w" "$image"`) if [ ${bits[0]} -gt ${bits[1]} ] then sizes=(600x800 81x108) else sizes=(800x600 108x81) fi ext=${image##*.} /usr/bin/convert -resize ${sizes[0]}! "$image" "${image/.$ext/-l.$ +ext}" /usr/bin/convert -resize ${sizes[1]}! "$image" "${image/.$ext/-s.$ +ext}" done

Update: Fixed a few subtle problems in the script that surfaced with more extensive testing (not that anybody will care, this not being Perl - but I do. :)


-- 
Human history becomes more and more a race between education and catastrophe. -- HG Wells

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://681803]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 14:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found