You are looking at historical revision 12512 of this page. It may differ significantly from its current revision.
Chicken bindings for the epeg thumbnailer library from the enlightenment project.
Epeg works by first opening a file, then setting the desired properties of the scaled image. Upon encoding, these properties are taken into account. Decoding is deferred until encoding of the new image takes place for optimal speed.
Image creation, destruction and friends[procedure] (image-open filename) => image
Returns a new epeg image object which describes the image stored in the file filename.[procedure] (image? img) => boolean
Determine if img is an epeg image object.[procedure] (image-close img)
Destroy the image and close the associated file.[procedure] (image-encode img)
Store the encoded image on disk. The filename is determined by image-file-output-set!. Other properties of the image can be set by the procedures described below.
Image properties[procedure] (image-size img) => integer integer
Returns 2 values: the width and height of the original image.[procedure] (image-file-output-set! img filename)
Set the output file for subsequent calls to image-encode.[procedure] (image-size-set! img width height)
Set the size of the new image, in pixels. The original image is decoded into this size.[procedure] (image-bounds-set! img x y width height)
Set the bounds of the image to be decoded. This is like cropping the image upon loading it.[procedure] (image-colorspace-set! img colorspace)
Set the colorspace for decoding. This is one of the following:[constant] colorspace-gray8
[procedure] (image-colorspace img) => colorspace
Returns the current colorspace value to use for decoding. The values returned by this is any of the constants described under image-colorspace-set!.[procedure] (image-comment-set! img comment)
Set the comment string for encoding. By default, this is not written to the thumbnail! Use image-comment-enable to enable this.[procedure] (image-comment img) => string
Returns the comment string to use for encoding, or #f if none was set.[procedure] (image-comment-enable img)
Enable comment field for the thumbnail.[procedure] (image-comment-disable img)
Disable comment field for the thumbnail. The default setting for comments is disabled.[procedure] (image-thumbnail-info img) => string string string string
Returns the 4 values: the uri field, width, height and mimetype of the thumbnail that will be written.[procedure] (image-quality-set! img percentage)
Set the thumbnail's image quality (0 - 100).[procedure] (image-trim img)
Pixel query procedures
Currently, the pixel query procedures are not available.
What follows is an almost literal translation of src/bin/epeg_main.c from the epeg distribution tarball.
<example> <init> (use epeg) </init> <expr> (unless (= (length (argv)) 3)
(printf "Usage: ~A input.jpg thumb.jpg\n" (car (argv))) (exit 0))
- This will throw an i/o file exception if the file can't be opened
(define im (image-open (list-ref (argv) 1)))
(let ((com (image-comment im)))
(when com (printf "Comment: ~A\n" com)))
(lambda () (image-thumbnail-info im)) (lambda (uri width height mimetype) (when mimetype (printf "Thumb Mimetype: ~A\n" mimetype) (when uri (printf "Thumb URI: ~A\n" uri)) (printf "Thumb Mtime: \n") (printf "Thumb Width: ~A\n" width) (printf "Thumb Height: ~A\n" height))))
(lambda () (image-size im)) (lambda (width height) (printf "Image size: ~Ax~A\n" width height)))
(image-size-set! im 128 96) (image-quality-set! im 80) (image-comment-enable im) (image-comment-set! im "Smelly pants!") (image-file-output-set! im (list-ref (argv) 2)) (image-encode im) (image-close im) ; Not required, cleanup on GC
(exit 0) </expr>
- 2.2 Port to Chicken 4, renamed procedures and removed epeg: prefix, converted to wiki documentation
- 2.1 Fix epeg:file-open failure when file not found
- 2.0 Change API to use epeg: prefix for procedures. Change to eggdoc documentation format. Use GC finalizers.
- 1.1 Added checks so (where it's possible) exceptions get thrown instead of segfaulting.
- 1.0 initial release.
Copyright (c) 2004-2008, Peter Bex All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.