Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: How Scheme and Perl Became Friends

by beppu (Friar)
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.

create-thumbnail.scm

#!/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) )


Comment on Re: How Scheme and Perl Became Friends
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-10-31 21:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (224 votes), past polls