You are looking at historical revision 14833 of this page. It may differ significantly from its current revision.
epeg
Description
Chicken bindings for the epeg thumbnailer library from the enlightenment project.
Author
Requirements
None
Documentation
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) => imageReturns a new epeg image object which describes the image stored in the file filename.
[procedure] (image? img) => booleanDetermine 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 integerReturns 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[constant] colorspace-yuv8
[constant] colorspace-rgb8
[constant] colorspace-bgr8
[constant] colorspace-rgba8
[constant] colorspace-bgra8
[constant] colorspace-argb32
[constant] colorspace-cmyk
[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) => stringReturns 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 stringReturns 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)Undocumented.
Pixel query procedures
Currently, the pixel query procedures are not available.
Example
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)