Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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

In reply to Re: How Scheme and Perl Became Friends by beppu
in thread How Scheme and Perl Became Friends by beppu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2021-12-07 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (34 votes). Check out past polls.

    Notices?