|lisp-magick||root / software|
2. Short DescriptionAn ImageMagick binding for Common Lisp
For documentation on the ImageMagick (MagickWand) API see the C-API documentation. The following conventions are used:
A few with-style macros are provided to manage proper deallocation of ImageMagick resources. See utils.lisp.
The binding is not yet complete, but new functions can easily be added.
(defpackage :lisp-magick-examples (:use :cl :lisp-magick)) (in-package :lisp-magick-examples) (defun create-thumbnail (filename thumbname width height) "Create a thumbnail the image in FILENAME with a max size of WIDTH x HEIGHT pixel (but with the original aspect ratio) and save it in THUMBNAME." (with-magick-wand (wand :load filename) (let ((a (/ (magick-get-image-width wand) (magick-get-image-height wand)))) (if (> a (/ width height)) (magick-scale-image wand width (truncate (/ width a))) (magick-scale-image wand (truncate (* a height)) height))) (magick-write-image wand thumbname))) (defun draw-a-few-lines (filename width height) "Create a new image with WIDTH x HEIGHT pixel containing 50 random lines and save it in FILENAME." (with-magick-wand (wand :create width height :comp (0 0 0)) (with-drawing-wand (dw) (with-pixel-wand (pw :comp (255 255 255)) (draw-set-stroke-color dw pw)) (draw-set-stroke-width dw 3d0) (dotimes (i 50) (draw-line dw (coerce (random width) 'double-float) (coerce (random height) 'double-float) (coerce (random width) 'double-float) (coerce (random height) 'double-float))) (magick-draw-image wand dw)) (magick-write-image wand filename)))
Copyright (c) 2006, 2007, 2008, 2009 Hans Bulfone 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 his 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 OWNER 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.
|Send comments, suggestions, etc. to me.|