Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: thumbnails generator

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


in reply to thumbnails generator

Since you're not really using Perl to do anything but arrange the various *nix programs, why not use a shell script instead? It would be simpler, shorter, and wouldn't involve spawning an unnecessary interpreter.

#!/bin/bash for image in *.{gif,bmp,jpg,wmf,jpeg,png} do size=`/usr/bin/identify $image` ... [do whatever with "$size" here] ... convert -geometry 800x600 $image ${image/./-l.} convert -geometry 80x60 $image ${image/./-s.} done

...and so on. This may be just a personal quirk of mine, but I find shell scripts (or batch files) coerced into another language (whatever it happens to be) gratingly pointless.

Update: Incidentally, it fails in Linux.

ben@Tyr:/tmp/Sorayama$ ../thumbnail hajime1.jpg hajime10.jpg hajime2.jpg hajime3.jpg hajime4.jpg hajime5.jpg hajime6.jpg hajime7.jpg hajime8.jpgconverting hajime1.jpg ... convert: invalid argument for option `hajime1-l.jpgxhajime1.jpg!': -re +size. convert: invalid argument for option `hajime1-s.jpgxhajime1.jpg!': -re +size. converting hajime10.jpg ... converting hajime2.jpg ... convert: invalid argument for option `hajime2-l.jpgxhajime2.jpg!': -re +size. convert: invalid argument for option `hajime2-s.jpgxhajime2.jpg!': -re +size. converting hajime3.jpg ... convert: invalid argument for option `hajime3-l.jpgxhajime3.jpg!': -re +size. convert: invalid argument for option `hajime3-s.jpgxhajime3.jpg!': -re +size. converting hajime4.jpg ... convert: invalid argument for option `hajime4-l.jpgxhajime4.jpg!': -re +size. convert: invalid argument for option `hajime4-s.jpgxhajime4.jpg!': -re +size. converting hajime5.jpg ... convert: invalid argument for option `hajime5-l.jpgxhajime5.jpg!': -re +size. convert: invalid argument for option `hajime5-s.jpgxhajime5.jpg!': -re +size. converting hajime6.jpg ... convert: invalid argument for option `hajime6-l.jpgxhajime6.jpg!': -re +size. convert: invalid argument for option `hajime6-s.jpgxhajime6.jpg!': -re +size. converting hajime7.jpg ... converting hajime8.jpg ... convert: invalid argument for option `hajime8-l.jpgxhajime8.jpg!': -re +size. convert: invalid argument for option `hajime8-s.jpgxhajime8.jpg!': -re +size.

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

Replies are listed 'Best First'.
Re^2: thumbnails generator
by spx2 (Deacon) on Apr 20, 2008 at 16:17 UTC
    I agree but I don't know much bash/shell scripting so I'm using what I know.
    Also shell scripting is not very flexible.In particular,what you wrote there
    in brackets "do whatever with $size here" will probably not be accomlished
    very easily using shell scripting.

      Actually, it is indeed accomplished very easily. The fact that it's so complicated in your script is a demonstration that you're coercing a square peg into a round hole.

      size=`/usr/bin/identify "$image"|/usr/bin/cut -d' ' -f 3` /usr/bin/convert -geometry "$size" "$old_name" "$new_name"
      
      -- 
      Human history becomes more and more a race between education and catastrophe. -- HG Wells
      

        Of course given a better shell you can do even more inline:

        size=${=${$(identify "$image")}[3]}

        (And people say Perl is executable line noise . . . :)

        The cake is a lie.
        The cake is a lie.
        The cake is a lie.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-28 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found