chickadee » epeg

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

epeg

Description

Chicken bindings for the epeg thumbnailer library from the enlightenment project.

Author

Peter Bex

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

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 properties

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:

colorspace-gray8constant
colorspace-yuv8constant
colorspace-rgb8constant
colorspace-bgr8constant
colorspace-rgba8constant
colorspace-bgra8constant
colorspace-argb32constant
colorspace-cmykconstant
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

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)

Changelog

License

 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.

Contents »