Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (7)
    As of 2015-07-03 20:59 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (56 votes), past polls