Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: How Scheme and Perl Became Friends

by beppu (Hermit)
on Feb 22, 2002 at 17:50 UTC ( #146951=note: print w/replies, xml ) Need Help??

in reply to How Scheme and Perl Became Friends

/me looks at the speechless monks...

Here's the example script that I used in the column. It's not great code, but I had time and space limitations that were kicking my ass, but enough excuses... It shows a little Perl being embedded inside a Scheme script, and that's all that counts for now.


#!/usr/bin/env gimp-request (begin ; This is a helper function that puts ; the contents of @ARGV into the ; Scheme variable, argv. {set_argv} ; This uses perl's regexes to create ; filenames for the thumbnails. Doing ; this in Scheme would be harder. (set! outfiles '{ sexp_from_list( map { s/\..*$/-thumbnail.png/; $_ } @ARGV) }) ; configure your scaling factor (set! scale 0.30) ; This is a function for resizing and saving images (define (resize filename) (let* ((image (car (gimp-file-load 0 filename filename))) (drawable nil) (wd (car (gimp-image-width image))) (hi (car (gimp-image-height image))) (_wd (* wd scale)) (_hi (* hi scale)) (new-filename nil)) (gimp-image-scale image _wd _hi) (set! drawable (car (gimp-image-flatten image))) (set! new-filename (car outfiles)) (set! outfiles (cdr outfiles)) (gimp-file-save 1 image drawable new-filename new-filename) (gimp-image-delete image) )) ; Finally, make a thumbnail out of every file in argv (for-each resize argv) )

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://146951]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2017-02-25 03:13 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (365 votes). Check out past polls.