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-open filenameprocedure
Returns a new epeg image object which describes the image stored in the file filename.
- image? imgprocedure
Determine if img is an epeg image object.
- image-close imgprocedure
Destroy the image and close the associated file.
- image-encode imgprocedure
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-size imgprocedure
Returns 2 values: the width and height of the original image.
- image-file-output-set! img filenameprocedure
Set the output file for subsequent calls to image-encode.
- image-size-set! img width heightprocedure
Set the size of the new image, in pixels. The original image is decoded into this size.
- image-bounds-set! img x y width heightprocedure
Set the bounds of the image to be decoded. This is like cropping the image upon loading it.
- image-colorspace-set! img colorspaceprocedure
Set the colorspace for decoding. This is one of the following:
- image-colorspace imgprocedure
Returns the current colorspace value to use for decoding. The values returned by this is any of the constants described under image-colorspace-set!.
- image-comment-set! img commentprocedure
Set the comment string for encoding. By default, this is not written to the thumbnail! Use image-comment-enable to enable this.
- image-comment imgprocedure
Returns the comment string to use for encoding, or #f if none was set.
- image-comment-enable imgprocedure
Enable comment field for the thumbnail.
- image-comment-disable imgprocedure
Disable comment field for the thumbnail. The default setting for comments is disabled.
- image-thumbnail-info imgprocedure
Returns the 4 values: the uri field, width, height and mimetype of the thumbnail that will be written.
- image-quality-set! img percentageprocedure
Set the thumbnail's image quality (0 - 100).
- image-trim imgprocedure
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.
(use epeg) (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))) (call-with-values (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)))) (call-with-values (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)
- 2.4 Convert deprecated pointer type to c-pointer so it works with new Chicken versions (thanks to Christian Kellermann).
- 2.3 Make use of epeg-config
- 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-2011, 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.