├── test ├── mortenhannemose.png └── test.lisp ├── packages.lisp ├── quantum.lisp ├── lisp-magick-wand.asd ├── .github └── workflows │ └── ci.yml ├── LICENSE ├── option.lisp ├── README.md ├── examples └── image-class.lisp ├── enums.lisp ├── types.lisp ├── utils.lisp ├── base.lisp └── magick.lisp /test/mortenhannemose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruricolist/lisp-magick-wand/master/test/mortenhannemose.png -------------------------------------------------------------------------------- /packages.lisp: -------------------------------------------------------------------------------- 1 | (defpackage :lisp-magick-wand 2 | (:nicknames :magick) 3 | (:use :common-lisp) 4 | (:export :quantum-8 :quantum-16 :quantum-32 :quantum-64 5 | :byte->quantum :quantum->byte 6 | :with-pixel-wand :with-drawing-wand :with-magick-wand :give-wand 7 | :with-pixel-data :pixel :get-pixel :set-pixel 8 | :magick-wand-error)) 9 | -------------------------------------------------------------------------------- /quantum.lisp: -------------------------------------------------------------------------------- 1 | (in-package :lisp-magick-wand) 2 | 3 | (defmagickfun "MagickGetQuantumDepth" :string ((depth (:out :ulong)))) 4 | 5 | (let ((qdepth (nth-value 1 (get-quantum-depth)))) 6 | (case qdepth 7 | (8 (push 'quantum-8 *features*)) 8 | (16 (push 'quantum-16 *features*)) 9 | (32 (push 'quantum-32 *features*)) 10 | (64 (push 'quantum-64 *features*)) 11 | (t (error "quantum depth ~a not supported" qdepth)))) 12 | -------------------------------------------------------------------------------- /lisp-magick-wand.asd: -------------------------------------------------------------------------------- 1 | (defsystem "lisp-magick-wand" 2 | :name "lisp-magick-wand" 3 | :author "Hans Bulfone" 4 | :licence "BSD" 5 | :maintainer "Paul M. Rodriguez " 6 | :description "ImageMagick binding" 7 | :homepage "https://github.com/ruricolist/lisp-magick-wand" 8 | :source-control (:git "https://github.com/ruricolist/lisp-magick-wand.git") 9 | :serial t 10 | :in-order-to ((test-op (test-op "lisp-magick-wand/test"))) 11 | :depends-on ("alexandria" "cffi") 12 | :components ((:file "packages") 13 | (:file "base") 14 | (:file "quantum") 15 | (:file "types") 16 | (:file "option") 17 | (:file "enums") 18 | (:file "magick") 19 | (:file "utils"))) 20 | 21 | (defsystem "lisp-magick-wand/test" 22 | :description "Test suite for lisp-magick-wand" 23 | :author "Paul M. Rodriguez " 24 | :license "MIT" 25 | :depends-on ("lisp-magick-wand" "fiveam" "trivial-file-size") 26 | :perform (test-op (o c) (symbol-call :lisp-magick-wand/test :run-tests)) 27 | :pathname "test/" 28 | :serial t 29 | :components ((:file "test"))) 30 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | env: 6 | DYNAMIC_SPACE_SIZE_MB: '16384' 7 | 8 | jobs: 9 | test: 10 | name: Test 11 | runs-on: ubuntu-latest 12 | container: fedora:42 13 | steps: 14 | 15 | - name: Install dependencies 16 | run: | 17 | yum install -y ImageMagick-devel sbcl wget 18 | 19 | - name: Install Quicklisp 20 | run: | 21 | cd 22 | wget https://beta.quicklisp.org/quicklisp.lisp 23 | sbcl --disable-debugger --load ~/quicklisp.lisp --eval '(quicklisp-quickstart:install)' --quit 24 | 25 | - name: Clone 26 | uses: actions/checkout@v4 27 | 28 | - name: Load lisp-magic-wand 29 | run: | 30 | export CL_SOURCE_REGISTRY="$(pwd):" 31 | sbcl \ 32 | --dynamic-space-size ${DYNAMIC_SPACE_SIZE_MB} \ 33 | --disable-debugger \ 34 | --load ~/quicklisp/setup.lisp \ 35 | --eval '(ql:register-local-projects)' \ 36 | --eval '(ql:quickload :lisp-magick-wand)' \ 37 | --quit 38 | 39 | - name: Test lisp-magic-wand 40 | run: | 41 | export CL_SOURCE_REGISTRY="$(pwd):" 42 | sbcl \ 43 | --dynamic-space-size ${DYNAMIC_SPACE_SIZE_MB} \ 44 | --disable-debugger \ 45 | --load ~/quicklisp/setup.lisp \ 46 | --eval '(ql:register-local-projects)' \ 47 | --eval '(ql:quickload :lisp-magick-wand/test)' \ 48 | --eval '(setf fiveam:*on-failure* :debug)' \ 49 | --eval '(asdf:test-system :lisp-magick-wand)' \ 50 | --quit 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ImageMagick binding for Common Lisp 2 | Copyright (c) 2006, 2007, 2008, 2009 Hans Bulfone 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the author nor the names of his contributors may 14 | be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 19 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 21 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /option.lisp: -------------------------------------------------------------------------------- 1 | (in-package :lisp-magick-wand) 2 | 3 | (cffi:defcstruct option-info 4 | (mnemonic magick-string) 5 | (type :long)) 6 | 7 | (defmagickfun "GetCommandOptions" (:array magick-string/free nil :err-val nil) 8 | ((table :int))) 9 | (defmagickfun "ParseCommandOption" :long 10 | ((table :int) (list-p :boolean) (options magick-string))) 11 | 12 | (defparameter *list-options* 13 | (loop for i from 0 upto 100 14 | for opts = (get-command-options i) 15 | when (and (member "List" opts :test #'equal) 16 | (member "Orientation" opts :test #'equal)) 17 | return i 18 | finally (error "Cannot find option list using GetMagickOptions"))) 19 | 20 | (defun magick-name-to-lisp-name (magick-name package) 21 | (intern 22 | (coerce 23 | (loop for prev = nil then ch 24 | for ch across magick-name 25 | when (or (and prev (not (upper-case-p prev)) 26 | (upper-case-p ch)) 27 | (and prev (not (digit-char-p prev)) 28 | (digit-char-p ch))) 29 | collect #\- 30 | collect (char-upcase ch)) 31 | 'string) 32 | package)) 33 | 34 | (defun find-magick-option (table options) 35 | (dolist (opt (if (listp options) options (list options))) 36 | (let ((n (parse-command-option table nil opt))) 37 | (unless (eql n -1) 38 | (return n))))) 39 | 40 | (defmacro define-enum-from-options (option-name lisp-name) 41 | (let ((id (or (find-magick-option *list-options* option-name) 42 | (error "cannot get info about ~s" option-name)))) 43 | (let ((names (remove-if #'(lambda (s) (and (eql (length s) 1) 44 | (digit-char-p (char s 0)))) 45 | (remove-duplicates (get-command-options id) :test #'equal)))) 46 | (unless names 47 | (error "unable to get option names for ~s/~s" option-name id)) 48 | `(cffi:defcenum ,lisp-name 49 | ,@(loop for name in names 50 | collect (list (magick-name-to-lisp-name name :keyword) 51 | (parse-command-option id nil name))))))) 52 | -------------------------------------------------------------------------------- /test/test.lisp: -------------------------------------------------------------------------------- 1 | (defpackage :lisp-magick-wand/test 2 | (:use :cl :fiveam :lisp-magick-wand :trivial-file-size)) 3 | (in-package :lisp-magick-wand/test) 4 | 5 | (defun draw-a-few-lines (filename width height) 6 | "Create a new image with WIDTH x HEIGHT pixel containing 50 random lines 7 | and save it in FILENAME." 8 | (magick:with-magick-wand (wand :create width height :comp (0 0 0)) 9 | (magick:with-drawing-wand (dw) 10 | (magick:with-pixel-wand (pw :comp (255 255 255)) 11 | (magick:draw-set-stroke-color dw pw)) 12 | (magick:draw-set-stroke-width dw 3d0) 13 | (dotimes (i 50) 14 | (magick:draw-line dw 15 | (coerce (random width) 'double-float) 16 | (coerce (random height) 'double-float) 17 | (coerce (random width) 'double-float) 18 | (coerce (random height) 'double-float))) 19 | (magick:draw-image wand dw)) 20 | (magick:write-image wand filename))) 21 | 22 | (def-suite lisp-magick-wand) 23 | (in-suite lisp-magick-wand) 24 | 25 | (defun run-tests () 26 | (let ((*on-failure* :debug)) 27 | (run! 'lisp-magick-wand))) 28 | 29 | (test draw-a-few-lines 30 | (uiop:with-temporary-file (:pathname p :type "jpeg") 31 | (finishes 32 | (draw-a-few-lines (namestring p) 33 | 100 100)) 34 | (is (uiop:file-exists-p p)) 35 | (is (> (file-size-in-octets p) 0)))) 36 | 37 | (cffi:defcfun "MagickReadImageBlob" :boolean 38 | (wand :pointer) 39 | (blob :pointer) 40 | (length :int)) 41 | 42 | (defun get-input-byte-vector () 43 | (alexandria:read-file-into-byte-vector 44 | (asdf:system-relative-pathname 45 | "lisp-magick-wand" 46 | "test/mortenhannemose.png"))) 47 | 48 | (defun slow () 49 | (magick:with-magick-wand (wand) 50 | (let ((bytes (get-input-byte-vector))) 51 | (magick:read-image-blob wand bytes)))) 52 | 53 | (defun fast () 54 | (magick:with-magick-wand (wand) 55 | (let ((bytes (get-input-byte-vector))) 56 | (cffi:with-pointer-to-vector-data (ptr bytes) 57 | (magickreadimageblob wand ptr (length bytes)))))) 58 | 59 | (test read-image-blob 60 | (finishes (slow)) 61 | (finishes (fast))) 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lisp-Magick-Wand 2 | 3 | Common Lisp bindings to ImageMagick's 4 | [MagicWand](http://www.imagemagick.org/script/magick-wand.php) API. \ 5 | This is a fork of [LISP-MAGICK][lisp-magick]. \ 6 | It is compatible with recent versions of ImageMagick (7.x) 7 | and has a slightly different API. 8 | 9 | ## Usage 10 | 11 | For the most part, you can use the [C API][api] as a reference. 12 | Translations follow a few simple rules: 13 | 14 | - Function names are lisp-ified. For example, `MagickGetImageWidth` 15 | becomes `magick:get-image-width`. Note that we omit any redundant 16 | `Magick` prefix. 17 | - Functions that return multiple results via pointer arguments return 18 | multiple values. 19 | - In most cases, a failed operation is signaled as `magick-wand-error` 20 | condition. 21 | - When a function expects an array of values and its length, a vector 22 | or a list can be passed in CL-MAGICK, and the length parameter is 23 | omitted. `nil` is passed as a `NULL` pointer (but `#()` is not). 24 | 25 | ## Example 26 | 27 | ``` lisp 28 | (defpackage :lisp-magick-examples 29 | (:use :cl)) 30 | (in-package :lisp-magick-examples) 31 | 32 | (defun create-thumbnail (filename thumbname width height) 33 | "Create a thumbnail the image in FILENAME with a max size of WIDTH x HEIGHT 34 | pixel (but with the original aspect ratio) and save it in THUMBNAME." 35 | (magick:with-magick-wand (wand :load filename) 36 | (let ((a (/ (magick:get-image-width wand) 37 | (magick:get-image-height wand)))) 38 | (if (> a (/ width height)) 39 | (magick:scale-image wand width (truncate (/ width a))) 40 | (magick:scale-image wand (truncate (* a height)) height))) 41 | (magick:write-image wand thumbname))) 42 | 43 | (defun draw-a-few-lines (filename width height) 44 | "Create a new image with WIDTH x HEIGHT pixel containing 50 random lines 45 | and save it in FILENAME." 46 | (magick:with-magick-wand (wand :create width height :comp (0 0 0)) 47 | (magick:with-drawing-wand (dw) 48 | (magick:with-pixel-wand (pw :comp (255 255 255)) 49 | (magick:draw-set-stroke-color dw pw)) 50 | (magick:draw-set-stroke-width dw 3d0) 51 | (dotimes (i 50) 52 | (magick:draw-line dw 53 | (coerce (random width) 'double-float) 54 | (coerce (random height) 'double-float) 55 | (coerce (random width) 'double-float) 56 | (coerce (random height) 'double-float))) 57 | (magick:draw-image wand dw)) 58 | (magick:write-image wand filename))) 59 | ``` 60 | 61 | ## Contributors 62 | 63 | - [Hans Bulfone](http://www.nil.at/) 64 | - [Paul M. Rodriguez](https://github.com/ruricolist) 65 | - [Dmitrii Kosenkov](https://github.com/Junker) 66 | 67 | 68 | [api]: http://www.imagemagick.org/script/magick-wand.php 69 | [lisp-magick]: http://www.nil.at/software/lisp-magick.html 70 | -------------------------------------------------------------------------------- /examples/image-class.lisp: -------------------------------------------------------------------------------- 1 | (defpackage image 2 | (:use #:cl 3 | #:alexandria) 4 | (:import-from #:serapeum 5 | #:lret 6 | #:in)) 7 | (in-package #:image) 8 | 9 | (defclass image () 10 | ((wand :initarg :wand 11 | :accessor image-wand 12 | :initform (magick:new-magick-wand)))) 13 | 14 | 15 | (defmethod initialize-instance :after ((img image) &key) 16 | (let ((wand (image-wand img))) 17 | (trivial-garbage:finalize img 18 | (lambda () (magick:destroy-magick-wand wand))))) 19 | 20 | (defmethod after-load ((img image)) 21 | (magick:auto-orient-image (image-wand img)) 22 | (magick:strip-image (image-wand img))) 23 | 24 | ;; PUBLIC 25 | (defun make-from-file (path) 26 | (lret ((img (make-instance 'image))) 27 | (magick:read-image (image-wand img) path) 28 | (after-load img))) 29 | 30 | (defun make-from-octets (data) 31 | (lret ((img (make-instance 'image))) 32 | (magick:read-image-blob (image-wand img) data) 33 | (after-load img))) 34 | 35 | (defmethod clone ((img image)) 36 | (make-instance 'image 37 | :wand (magick:clone-magick-wand (image-wand img)))) 38 | 39 | (defmethod get-data ((img image) &optional (format "JPEG") (quality 90)) 40 | (magick:set-image-compression-quality (image-wand img) quality) 41 | (magick:set-image-format (image-wand img) format) 42 | (magick:get-image-blob (image-wand img))) 43 | 44 | (defmethod save-to-file ((img image) path &optional (quality 90)) 45 | (magick:set-image-compression-quality (image-wand img) quality) 46 | (magick:write-image (image-wand img) path)) 47 | 48 | (defmethod crop ((img image) x y width height) 49 | (magick:crop-image (image-wand img) width height x y)) 50 | 51 | (defmethod resize ((img image) width height &optional (filter :lanczos)) 52 | (magick:resize-image (image-wand img) width height filter)) 53 | 54 | (defmethod downscale-with-aspect-ratio ((img image) new-width new-height) 55 | (assert (or (numberp new-width) (numberp new-height))) 56 | (let* ((width (magick:get-image-width (image-wand img))) 57 | (height (magick:get-image-height (image-wand img))) 58 | (ratio (min (if (numberp new-width) (/ new-width width) 1000000) 59 | (if (numberp new-height) (/ new-height height) 1000000)))) 60 | (when (< ratio 1) 61 | (resize img (round (* width ratio)) (round (* height ratio)))))) 62 | 63 | (defmethod thumbnail ((img image) width height) 64 | (let* ((img-width (magick:get-image-width (image-wand img))) 65 | (img-height (magick:get-image-height (image-wand img))) 66 | (ratio (max (/ width img-width) (/ height img-height))) 67 | (tmp-width (round (* img-width ratio))) 68 | (tmp-height (round (* img-height ratio)))) 69 | (when (< ratio 1) 70 | (resize img tmp-width tmp-height)) 71 | (magick:crop-image (image-wand img) 72 | width height 73 | (round (/ (- tmp-width width) 2)) 74 | (round (/ (- tmp-height height) 2))))) 75 | -------------------------------------------------------------------------------- /enums.lisp: -------------------------------------------------------------------------------- 1 | (in-package :lisp-magick-wand) 2 | 3 | (cffi:defcenum exception-type 4 | (:undefined-exception 0) 5 | (:resource-limit-warning 300) 6 | (:type-warning 305) 7 | (:option-warning 310) 8 | (:delegate-warning 315) 9 | (:missing-delegate-warning 320) 10 | (:corrupt-image-warning 325) 11 | (:file-open-warning 330) 12 | (:blob-warning 335) 13 | (:stream-warning 340) 14 | (:cache-warning 345) 15 | (:coder-warning 350) 16 | (:module-warning 355) 17 | (:draw-warning 360) 18 | (:image-warning 365) 19 | (:wand-warning 370) 20 | (:xserver-warning 380) 21 | (:monitor-warning 385) 22 | (:registry-warning 390) 23 | (:configure-warning 395) 24 | (:resource-limit-error 400) 25 | (:type-error 405) 26 | (:option-error 410) 27 | (:delegate-error 415) 28 | (:missing-delegate-error 420) 29 | (:corrupt-image-error 425) 30 | (:file-open-error 430) 31 | (:blob-error 435) 32 | (:stream-error 440) 33 | (:cache-error 445) 34 | (:coder-error 450) 35 | (:module-error 455) 36 | (:draw-error 460) 37 | (:image-error 465) 38 | (:wand-error 470) 39 | (:xserver-error 480) 40 | (:monitor-error 485) 41 | (:registry-error 490) 42 | (:configure-error 495) 43 | (:resource-limit-fatal-error 700) 44 | (:type-fatal-error 705) 45 | (:option-fatal-error 710) 46 | (:delegate-fatal-error 715) 47 | (:missing-delegate-fatal-error 720) 48 | (:corrupt-image-fatal-error 725) 49 | (:file-open-fatal-error 730) 50 | (:blob-fatal-error 735) 51 | (:stream-fatal-error 740) 52 | (:cache-fatal-error 745) 53 | (:coder-fatal-error 750) 54 | (:module-fatal-error 755) 55 | (:draw-fatal-error 760) 56 | (:image-fatal-error 765) 57 | (:wand-fatal-error 770) 58 | (:xserver-fatal-error 780) 59 | (:monitor-fatal-error 785) 60 | (:registry-fatal-error 790) 61 | (:configure-fatal-error 795)) 62 | 63 | (define-enum-from-options ("Compression" "Compress") compression-type) 64 | (define-enum-from-options "Interlace" interlace-type) 65 | (define-enum-from-options ("Image" "Type") image-type) 66 | (define-enum-from-options "Gravity" gravity-type) 67 | (define-enum-from-options ("Composite" "Compose") composite-operator) 68 | (define-enum-from-options "Colorspace" colorspace-type) 69 | (define-enum-from-options "Dispose" dispose-type) 70 | (define-enum-from-options "Filter" filter-type) 71 | (define-enum-from-options "Resource" resource-type) 72 | (define-enum-from-options "Stretch" stretch-type) 73 | (define-enum-from-options "Style" style-type) 74 | (define-enum-from-options "Storage" storage-type) 75 | (define-enum-from-options "Align" align-type) 76 | (define-enum-from-options "ClipPath" clip-path-units) 77 | (define-enum-from-options "Decoration" decoration-type) 78 | (define-enum-from-options "FillRule" fill-rule) 79 | (define-enum-from-options "LineCap" line-cap) 80 | (define-enum-from-options "LineJoin" line-join) 81 | (define-enum-from-options "Method" paint-method) 82 | (define-enum-from-options "Noise" noise-type) 83 | (define-enum-from-options "Evaluate" magick-evaluate-operator) 84 | (define-enum-from-options "Metric" metric-type) 85 | (define-enum-from-options "Distort" distort-method) 86 | (define-enum-from-options "Orientation" orientation-type) 87 | (define-enum-from-options "Interpolate" pixel-interpolate-method) 88 | (define-enum-from-options "AutoThreshold" auto-threshold-method) 89 | (define-enum-from-options "Morphology" morphology-method) 90 | (define-enum-from-options "Dither" dither-method) 91 | (define-enum-from-options "SparseColor" sparse-color-method) 92 | (define-enum-from-options "Statistic" statistic-type) 93 | (define-enum-from-options "Endian" endian-type) 94 | (define-enum-from-options "Intent" rendering-intent) 95 | (define-enum-from-options "VirtualPixel" virtual-pixel-method) 96 | (define-enum-from-options "Alpha" alpha-channel-type) 97 | (define-enum-from-options "Layers" layer-method) 98 | (define-enum-from-options "Complex" complex-operator) 99 | (define-enum-from-options "PixelMask" pixel-mask) 100 | (define-enum-from-options "Mode" montage-mode) 101 | (define-enum-from-options "Preview" preview-type) 102 | 103 | 104 | (cffi:defbitfield channel-type 105 | ;; (:undefined #x00) 106 | (:red #x01) 107 | ;; (:gray #x01) 108 | ;; (:cyan #x01) 109 | (:green #x02) 110 | ;; (:magenta #x02) 111 | (:blue #x04) 112 | ;; (:yellow #x04) 113 | (:alpha #x08) 114 | ;; (:opacity #x08) 115 | ;; (:matte #x08) ; deprecated 116 | ;; (:black #x20) 117 | (:index #x20) 118 | (:all #xff)) 119 | -------------------------------------------------------------------------------- /types.lisp: -------------------------------------------------------------------------------- 1 | (in-package :lisp-magick-wand) 2 | 3 | (defmagickfun "MagickRelinquishMemory" :pointer ((ptr :pointer))) 4 | 5 | (defmacro defmagicktype (name base-type) 6 | `(cffi:define-foreign-type ,(type-name-to-class-name name) () () 7 | (:actual-type ,base-type) 8 | (:simple-parser ,name))) 9 | 10 | (defmacro defmagicktrans (method-name (value-arg (type-arg type-name) 11 | &rest other-args) 12 | &body body) 13 | `(defmethod ,method-name (,value-arg (,type-arg ,(type-name-to-class-name type-name)) 14 | ,@other-args) 15 | ,@body)) 16 | 17 | 18 | ;; size_t 19 | 20 | (defmagicktype size-t :uint) 21 | (defmagicktrans cffi:expand-to-foreign (value (type size-t)) value) 22 | (defmagicktrans cffi:expand-from-foreign (value (type size-t)) value) 23 | 24 | 25 | ;; magick-double 26 | 27 | (defmagicktype magick-double :double) 28 | (defmagicktrans cffi:expand-to-foreign (value (type magick-double)) 29 | `(coerce ,value 'double-float)) 30 | (defmagicktrans cffi:expand-from-foreign (value (type magick-double)) 31 | value) 32 | (defmagicktrans cffi:translate-to-foreign (value (type magick-double)) 33 | (values (coerce value 'double-float) nil)) 34 | 35 | 36 | ;; Quantum 37 | 38 | (declaim (inline byte->quantum quantum->byte)) 39 | 40 | #+lisp-magick-wand:quantum-8 41 | (progn 42 | (defmagicktype quantum :uint8) 43 | (defun byte->quantum (b) b) 44 | (defun quantum->byte (b) b)) 45 | 46 | #+lisp-magick-wand:quantum-16 47 | (progn 48 | (defmagicktype quantum :uint16) 49 | (defun byte->quantum (b) (* b 257)) 50 | (defun quantum->byte (b) (values (truncate b 257)))) 51 | 52 | #+lisp-magick-wand:quantum-32 53 | (progn 54 | (defmagicktype quantum :uint32) 55 | (defun byte->quantum (b) (* b 16843009)) 56 | (defun quantum->byte (b) (values (truncate b 16843009)))) 57 | 58 | #+(and lisp-magick-wand:quantum-64 cffi-features:no-long-long) 59 | (error "your version of imagemagick uses a quantum size of 64bit, 60 | but cffi doesn't support long long on your lisp implementation.") 61 | 62 | #+(and lisp-magick-wand:quantum-64 (not cffi-features:no-long-long)) 63 | (progn 64 | (defmagicktype quantum :uint64) 65 | (defun byte->quantum (b) (* b 72340172838076673)) 66 | (defun quantum->byte (b) (values (truncate b 72340172838076673)))) 67 | 68 | #-(or lisp-magick-wand:quantum-8 lisp-magick-wand:quantum-16 69 | lisp-magick-wand:quantum-32 lisp-magick-wand:quantum-64) 70 | (error "quantum size feature not defined") 71 | 72 | (defmagicktrans cffi:expand-to-foreign (value (type quantum)) value) 73 | (defmagicktrans cffi:expand-from-foreign (value (type quantum)) value) 74 | 75 | 76 | ;; Boolean 77 | 78 | (defmethod %error-condition (value (type (eql :boolean))) 79 | `(not ,value)) 80 | 81 | ;; String Types 82 | 83 | ;; this is cffi:defctype (and not defmagicktype) on purpose 84 | ;; - we want to inherit :string's translators 85 | (cffi:defctype magick-string :string) 86 | (defmethod %error-condition (value (type (eql 'magick-string))) 87 | `(null ,value)) 88 | 89 | (defmagicktype magick-string/free :pointer) 90 | (defmagicktrans cffi:translate-from-foreign (value (type magick-string/free)) 91 | (prog1 92 | (cffi:foreign-string-to-lisp value) 93 | (unless (cffi:null-pointer-p value) 94 | (relinquish-memory value)))) 95 | (defmagicktrans cffi:translate-to-foreign (value (type magick-string/free)) 96 | (values (cffi:foreign-string-alloc value) t)) 97 | (defmagicktrans cffi:free-translated-object (value (type magick-string/free) free-p) 98 | (when free-p 99 | (cffi:foreign-string-free value))) 100 | (defmagicktrans cffi:expand-from-foreign (value (type magick-string/free)) 101 | (let ((g (gensym))) 102 | `(let ((,g ,value)) 103 | (prog1 104 | (cffi:foreign-string-to-lisp ,g) 105 | (unless (cffi:null-pointer-p ,g) 106 | (relinquish-memory ,g)))))) 107 | 108 | (defmethod %error-condition (value (type (eql 'magick-string/free))) 109 | `(null ,value)) 110 | 111 | ;; MagickWand 112 | 113 | (defmagicktype magick-wand :pointer) 114 | (defmagicktrans cffi:expand-to-foreign (value (type magick-wand)) value) 115 | (defmagicktrans cffi:expand-from-foreign (value (type magick-wand)) value) 116 | (defmethod %error-condition (value (type (eql 'magick-wand))) 117 | `(cffi:null-pointer-p ,value)) 118 | (defmethod %error-signalling-code (wand (type (eql 'magick-wand))) 119 | `(signal-magick-wand-error ,wand)) 120 | 121 | 122 | ;; PixelWand 123 | 124 | (defmagicktype pixel-wand :pointer) 125 | (defmagicktrans cffi:expand-to-foreign (value (type pixel-wand)) value) 126 | (defmagicktrans cffi:expand-from-foreign (value (type pixel-wand)) value) 127 | (defmethod %error-condition (value (type (eql 'pixel-wand))) 128 | `(cffi:null-pointer-p ,value)) 129 | (defmethod %error-signalling-code (wand (type (eql 'pixel-wand))) 130 | `(signal-pixel-wand-error ,wand)) 131 | 132 | 133 | ;; DrawingWand 134 | 135 | (defmagicktype drawing-wand :pointer) 136 | (defmagicktrans cffi:expand-to-foreign (value (type drawing-wand)) value) 137 | (defmagicktrans cffi:expand-from-foreign (value (type drawing-wand)) value) 138 | (defmethod %error-condition (value (type (eql 'drawing-wand))) 139 | `(cffi:null-pointer-p ,value)) 140 | (defmethod %error-signalling-code (wand (type (eql 'drawing-wand))) 141 | `(signal-drawing-wand-error ,wand)) 142 | -------------------------------------------------------------------------------- /utils.lisp: -------------------------------------------------------------------------------- 1 | (in-package :lisp-magick-wand) 2 | 3 | ;;; Pixel Wand Utilities 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | (defgeneric %init-pixel-wand (wand type args)) 7 | 8 | (defmethod %init-pixel-wand (wand (type (eql :string)) args) 9 | (destructuring-bind (color) args 10 | `((pixel-set-color ,wand ,color)))) 11 | 12 | (defmethod %init-pixel-wand (wand (type (eql :components)) args) 13 | (destructuring-bind ((r g b &optional a) &key (format :rgb) (type :byte)) args 14 | (unless (or (eql format :rgb) (eql format :rgba)) 15 | (error "invalid format ~a" format)) 16 | (ecase type 17 | (:double 18 | `((pixel-set-red ,wand ,r) 19 | (pixel-set-green ,wand ,g) 20 | (pixel-set-blue ,wand ,b) 21 | ,@(when a `((pixel-set-alpha ,wand ,a))))) 22 | (:quantum 23 | `((pixel-set-red-quantum ,wand ,r) 24 | (pixel-set-green-quantum ,wand ,g) 25 | (pixel-set-blue-quantum ,wand ,b) 26 | ,@(when a `((pixel-set-alpha-quantum ,wand ,a))))) 27 | (:byte 28 | `((pixel-set-red-quantum ,wand (byte->quantum ,r)) 29 | (pixel-set-green-quantum ,wand (byte->quantum ,g)) 30 | (pixel-set-blue-quantum ,wand (byte->quantum ,b)) 31 | ,@(when a `((pixel-set-alpha-quantum ,wand (byte->quantum ,a))))))))) 32 | 33 | (defmethod %init-pixel-wand (wand (type (eql :comp)) args) 34 | (%init-pixel-wand wand :components args)) 35 | 36 | (defmethod %init-pixel-wand (wand (type (eql :vector)) args) 37 | (destructuring-bind (v &key (format :rgb) (type :byte)) args 38 | (unless (or (eql format :rgb) (eql format :rgba)) 39 | (error "invalid format ~a" format)) 40 | (let ((g (gensym))) 41 | `((let ((,g ,v)) 42 | ,@ (ecase type 43 | (:double 44 | `((pixel-set-red ,wand (svref ,g 0)) 45 | (pixel-set-green ,wand (svref ,g 1)) 46 | (pixel-set-blue ,wand (svref ,g 2)) 47 | ,@(when (eql format :rgba) `((pixel-set-alpha ,wand (svref ,g 3)))))) 48 | (:quantum 49 | `((pixel-set-red-quantum ,wand (svref ,g 0)) 50 | (pixel-set-green-quantum ,wand (svref ,g 1)) 51 | (pixel-set-blue-quantum ,wand (svref ,g 2)) 52 | ,@(when (eql format :rgba) `((pixel-set-alpha-quantum ,wand (svref ,g 3)))))) 53 | (:byte 54 | `((pixel-set-red-quantum ,wand (byte->quantum (svref ,g 0))) 55 | (pixel-set-green-quantum ,wand (byte->quantum (svref ,g 1))) 56 | (pixel-set-blue-quantum ,wand (byte->quantum (svref ,g 2))) 57 | ,@(when (eql format :rgba) `((pixel-set-alpha-quantum ,wand (byte->quantum (svref ,g 3))))))))))))) 58 | 59 | (defmacro with-pixel-wand ((var &optional type &rest args) &body body) 60 | `(let ((,var (new-pixel-wand))) 61 | (unwind-protect 62 | (progn 63 | ,@(when type (%init-pixel-wand var type args)) 64 | ,@body) 65 | (destroy-pixel-wand ,var)))) 66 | 67 | 68 | ;;; Drawing Wand Utilities 69 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 70 | 71 | (defmacro with-drawing-wand ((var) &body body) 72 | `(let ((,var (new-drawing-wand))) 73 | (unwind-protect 74 | (progn ,@body) 75 | (destroy-drawing-wand ,var)))) 76 | 77 | 78 | ;;; Magick Wand Utilities 79 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 80 | 81 | (defgeneric %create-magick-wand (wand init args)) 82 | (defgeneric %init-magick-wand (wand init args)) 83 | 84 | (defmethod %create-magick-wand (wand init args) 85 | `(new-magick-wand)) 86 | 87 | (defmethod %init-magick-wand (wand (init (eql :create)) args) 88 | (destructuring-bind (width height &rest color) args 89 | (if (or (null color) (keywordp (car color))) 90 | (let ((pw (gensym))) 91 | `((with-pixel-wand (,pw ,@color) 92 | (new-image ,wand ,width ,height ,pw)))) 93 | `((new-image ,wand ,width ,height ,(car color)))))) 94 | 95 | (defmethod %init-magick-wand (wand (init (eql :load)) args) 96 | (destructuring-bind (filename &key jpeg-size) args 97 | `(,@(when jpeg-size 98 | (list 99 | (alexandria:once-only (jpeg-size) 100 | `(set-option ,wand "jpeg:size" 101 | (format nil "~dx~d" 102 | (car ,jpeg-size) 103 | (cdr ,jpeg-size)))))) 104 | (read-image ,wand (namestring (truename ,filename)))))) 105 | 106 | (defmethod %init-magick-wand (wand (init (eql :from)) args) 107 | nil) 108 | 109 | (defmethod %create-magick-wand (wand (init (eql :from)) args) 110 | `(progn ,@args)) 111 | 112 | (defmacro with-magick-wand ((var &optional init &rest args) &body body) 113 | "execute the body with var bound to a wand. 114 | the wand can optionally be initialized with an image loaded 115 | from disk: 116 | 117 | (with-magick-wand (wand :load filename) body...) 118 | 119 | or with a newly created image with the given size and color: 120 | 121 | (with-magick-wand (wand :create w h :components (0 0 0)) body...) 122 | 123 | When loading a JPEG image, you may want to specify the size for 124 | libjpeg (as a cons): 125 | 126 | (with-magick-wand (wand :load filename :jpeg-size '(200 . 200) ...) 127 | " 128 | 129 | `(let ((,var ,(%create-magick-wand var init args))) 130 | (unwind-protect 131 | (progn 132 | ,@(when init (%init-magick-wand var init args)) 133 | ,@body) 134 | (when ,var 135 | (destroy-magick-wand ,var))))) 136 | 137 | (defmacro give-wand (var) 138 | `(prog1 ,var (setf ,var nil))) 139 | 140 | ;;; Manipulating pixel data 141 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 142 | 143 | (defclass pixel-data () 144 | ((data :initarg :data :reader pd-data) 145 | (width :initarg :width :reader pd-width) 146 | (height :initarg :height :reader pd-height)) 147 | (:documentation "a wrapper around a foreign object containing raw pixel data")) 148 | 149 | (defmacro with-pixel-data ((var wand) &body body) 150 | (let ((g-wand (gensym)) (g-pd (gensym)) (g-w (gensym)) (g-h (gensym))) 151 | `(let* ((,g-wand ,wand) 152 | (,g-w (get-image-width ,g-wand)) 153 | (,g-h (get-image-height ,g-wand)) 154 | (,g-pd (cffi:foreign-alloc :uchar :count (* ,g-w ,g-h 4)))) 155 | (unwind-protect 156 | (progn 157 | (export-image-pixels ,g-wand 0 0 ,g-w ,g-h "RGBA" :char ,g-pd) 158 | (prog1 159 | (let ((,var (make-instance 'pixel-data :data ,g-pd :width ,g-w :height ,g-h))) 160 | ,@body) 161 | (import-image-pixels ,g-wand 0 0 ,g-w ,g-h "RGBA" :char ,g-pd))) 162 | (cffi:foreign-free ,g-pd))))) 163 | 164 | (defun pixel (pd x y) 165 | (let ((data (pd-data pd)) 166 | (i (+ (* (pd-width pd) y 4) (* x 4)))) 167 | (vector 168 | (cffi:mem-ref data :uchar i) 169 | (cffi:mem-ref data :uchar (+ i 1)) 170 | (cffi:mem-ref data :uchar (+ i 2)) 171 | (cffi:mem-ref data :uchar (+ i 3))))) 172 | 173 | (defun (setf pixel) (color pd x y) 174 | (let ((data (pd-data pd)) 175 | (i (+ (* (pd-width pd) y 4) (* x 4)))) 176 | (setf (cffi:mem-ref data :uchar i) (svref color 0) 177 | (cffi:mem-ref data :uchar (+ i 1)) (svref color 1) 178 | (cffi:mem-ref data :uchar (+ i 2)) (svref color 2) 179 | (cffi:mem-ref data :uchar (+ i 3)) (svref color 3)))) 180 | 181 | (defun get-pixel (pd x y) 182 | (let ((data (pd-data pd)) 183 | (i (+ (* (pd-width pd) y 4) (* x 4)))) 184 | (values 185 | (cffi:mem-ref data :uchar i) 186 | (cffi:mem-ref data :uchar (+ i 1)) 187 | (cffi:mem-ref data :uchar (+ i 2)) 188 | (cffi:mem-ref data :uchar (+ i 3))))) 189 | 190 | (defun set-pixel (pd x y r g b a) 191 | (let ((data (pd-data pd)) 192 | (i (+ (* (pd-width pd) y 4) (* x 4)))) 193 | (setf (cffi:mem-ref data :uchar i) r 194 | (cffi:mem-ref data :uchar (+ i 1)) g 195 | (cffi:mem-ref data :uchar (+ i 2)) b 196 | (cffi:mem-ref data :uchar (+ i 3)) a))) 197 | -------------------------------------------------------------------------------- /base.lisp: -------------------------------------------------------------------------------- 1 | (in-package :lisp-magick-wand) 2 | 3 | (defgeneric %error-condition (value type) 4 | (:documentation "return code for checking if VALUE of type TYPE indicates an error")) 5 | (defgeneric %error-signalling-code (wand type) 6 | (:documentation "return code for signaling an error reported by WAND of type TYPE")) 7 | (defgeneric %special-argument-handling (name key &rest args) 8 | (:documentation "perform special argument handling for defmagickfun")) 9 | (defgeneric %special-retval-handling (name key &rest args) 10 | (:documentation "perform special return value handling for defmagickfun")) 11 | 12 | (defun %magick-lisp-name (c-name) 13 | ;; Trim the Magick- prefix. 14 | (when (= (mismatch "Magick" c-name) 6) 15 | (setf c-name (subseq c-name 6))) 16 | (intern 17 | (with-output-to-string (s) 18 | (loop for lcase = nil then case 19 | for ch across c-name 20 | for case = (if (upper-case-p ch) :upper :lower) 21 | do (progn 22 | (when (and (eql lcase :lower) (eql case :upper)) 23 | (write-char #\- s)) 24 | (write-char (char-upcase ch) s)))))) 25 | 26 | (defun %internal-fn-name (sym &optional (prefix "%C%")) 27 | (intern (concatenate 'string prefix (symbol-name sym)) (symbol-package sym))) 28 | 29 | (defun %add-outer-wrapper (fn) 30 | (declare (special *outer-wrap-code*)) 31 | (setf *outer-wrap-code* 32 | (let ((old *outer-wrap-code*)) 33 | #'(lambda (code) 34 | (funcall old (funcall fn code)))))) 35 | 36 | (defun %add-inner-wrapper (fn) 37 | (declare (special *inner-wrap-code*)) 38 | (setf *inner-wrap-code* 39 | (let ((old *inner-wrap-code*)) 40 | #'(lambda (code) 41 | (funcall old (funcall fn code)))))) 42 | 43 | (defun %set-return-type (type) 44 | (declare (special *ret-type*)) 45 | (setf *ret-type* type)) 46 | 47 | (defun %add-result-value (form) 48 | (declare (special *result-values*)) 49 | (push form *result-values*)) 50 | 51 | (defun %add-defc-param (form) 52 | (declare (special *defc-params*)) 53 | (push form *defc-params*)) 54 | 55 | (defun %add-lisp-param (name) 56 | (declare (special *lisp-params*)) 57 | (push name *lisp-params*)) 58 | 59 | (defun %add-inv-param (form) 60 | (declare (special *inv-params*)) 61 | (push form *inv-params*)) 62 | 63 | (defun %get-state (key1 key2) 64 | (declare (special *state*)) 65 | (getf (getf *state* key1) key2)) 66 | 67 | (defun (setf %get-state) (val key1 key2) 68 | (declare (special *state*)) 69 | (setf (getf (getf *state* key1) key2) val)) 70 | 71 | (defmethod %special-argument-handling (name (key (eql :out)) &rest args) 72 | (destructuring-bind (real-type) args 73 | (let ((g (gensym))) 74 | (%add-outer-wrapper 75 | #'(lambda (code) 76 | `(cffi:with-foreign-object (,g ',real-type) 77 | ,code))) 78 | (%add-result-value `(cffi:mem-ref ,g ',real-type)) 79 | (%add-defc-param (list name :pointer)) 80 | (%add-inv-param g)))) 81 | 82 | #+sbcl 83 | (defmethod %special-argument-handling (name (key (eql :dynarray)) &rest rest) 84 | (declare (ignorable rest)) 85 | (let ((g-len (or (%get-state :dynarray-length name) 86 | (setf (%get-state :dynarray-length name) (gensym)))) 87 | (g-mem (gensym))) 88 | (%add-outer-wrapper 89 | #'(lambda (code) 90 | `(let ((,g-len (length ,name))) 91 | (unwind-protect 92 | (cffi:with-pointer-to-vector-data (,g-mem (coerce ,name 'vector)) 93 | ,code))))) 94 | (%add-defc-param (list name :pointer)) 95 | (%add-lisp-param name) 96 | (%add-inv-param g-mem))) 97 | 98 | #-sbcl 99 | (defmethod %special-argument-handling (name (key (eql :dynarray)) &rest args) 100 | (destructuring-bind (el-type) args 101 | (let ((g-len (or (%get-state :dynarray-length name) 102 | (setf (%get-state :dynarray-length name) (gensym)))) 103 | (g-mem (gensym)) (g-vals (gensym)) (g-params (gensym)) (g-idx (gensym)) (g-fv (gensym)) 104 | (g-p (gensym)) (g-i (gensym)) 105 | (real-type (cffi::canonicalize-foreign-type el-type))) 106 | (%add-outer-wrapper 107 | #'(lambda (code) 108 | `(let ((,g-len (length ,name)) 109 | (,g-vals nil) (,g-params nil) 110 | (,g-mem (cffi:null-pointer))) 111 | (unwind-protect 112 | (progn 113 | (etypecase ,name 114 | (null nil) 115 | (vector 116 | (setf ,g-mem (cffi:foreign-alloc ',real-type :count ,g-len)) 117 | (do ((,g-idx 0 (1+ ,g-idx))) 118 | ((>= ,g-idx ,g-len)) 119 | (multiple-value-bind (,g-fv ,g-p) 120 | (cffi:convert-to-foreign (aref ,name ,g-idx) ',el-type) 121 | (setf (cffi:mem-aref ,g-mem ',real-type ,g-idx) ,g-fv) 122 | (push ,g-fv ,g-vals) 123 | (push ,g-p ,g-params)))) 124 | (list 125 | (setf ,g-mem (cffi:foreign-alloc ',real-type :count ,g-len)) 126 | (do ((,g-idx 0 (1+ ,g-idx)) 127 | (,g-i ,name (cdr ,g-i))) 128 | ((>= ,g-idx ,g-len)) 129 | (multiple-value-bind (,g-fv ,g-p) 130 | (cffi:convert-to-foreign (car ,g-i) ',el-type) 131 | (setf (cffi:mem-aref ,g-mem ',real-type ,g-idx) ,g-fv) 132 | (push ,g-fv ,g-vals) 133 | (push ,g-p ,g-params))))) 134 | ,code) 135 | (unless (cffi:null-pointer-p ,g-mem) 136 | (mapc #'(lambda (,g-fv ,g-p) 137 | (cffi:free-converted-object ,g-fv ',el-type ,g-p)) 138 | ,g-vals ,g-params) 139 | (cffi:foreign-free ,g-mem)))))) 140 | (%add-defc-param (list name :pointer)) 141 | (%add-lisp-param name) 142 | (%add-inv-param g-mem)))) 143 | 144 | (defmethod %special-argument-handling (name (key (eql :dynarray-length)) &rest args) 145 | (destructuring-bind (type seq-name &key expr) args 146 | (let ((g-len (or (%get-state :dynarray-length seq-name) 147 | (setf (%get-state :dynarray-length seq-name) (gensym))))) 148 | (format t "length ~a~%" g-len) 149 | (%add-defc-param (list name type)) 150 | (%add-inv-param (if expr 151 | (subst g-len :l expr) 152 | g-len))))) 153 | 154 | (defmethod %special-argument-handling (name (key (eql :dynarray-ret-length)) &rest args) 155 | (destructuring-bind (type) args 156 | (let ((g (gensym))) 157 | (%add-outer-wrapper 158 | #'(lambda (code) 159 | `(cffi:with-foreign-object (,g ',type) 160 | ,code))) 161 | (%add-defc-param (list name :pointer)) 162 | (%add-inv-param g) 163 | (setf (%get-state :dynarray-ret-length :name) g 164 | (%get-state :dynarray-ret-length :type) type)))) 165 | 166 | (defmethod %special-retval-handling (name (key (eql :dynarray)) &rest args) 167 | (destructuring-bind (type &key (err-val :error) (seq-type 'list)) args 168 | (unless (constantp err-val) 169 | (error "error value must be constant")) 170 | (let ((g-len (or (%get-state :dynarray-ret-length :name) 171 | (error ":dynarray return type needs a :dynarray-ret-length parameter"))) 172 | (len-type (or (%get-state :dynarray-ret-length :type) 173 | (error ":dynarray return type needs a :dynarray-ret-length parameter"))) 174 | (g-i (gensym))) 175 | (%add-inner-wrapper 176 | #'(lambda (code) 177 | `(let ((,name (if (cffi:null-pointer-p ,name) 178 | ,err-val 179 | ,(cond 180 | ((eql seq-type 'list) 181 | `(loop for ,g-i from 0 below (cffi:mem-ref ,g-len ',len-type) 182 | collecting (cffi:mem-aref ,name ',type ,g-i) 183 | finally (relinquish-memory ,name))) 184 | ((or (eql seq-type 'vector) 185 | (and (listp seq-type) 186 | (eql (first seq-type) 'vector))) 187 | (let ((eltype (if (listp seq-type) (second seq-type) t)) 188 | (g-l (gensym)) 189 | (g-seq (gensym))) 190 | `(let* ((,g-l (cffi:mem-ref ,g-len ',len-type)) 191 | (,g-seq (make-array ,g-l :element-type ',eltype))) 192 | (dotimes (,g-i ,g-l) 193 | (setf (aref ,g-seq ,g-i) (cffi:mem-aref ,name ',type ,g-i))) 194 | (relinquish-memory ,name) 195 | ,g-seq))) 196 | (t (error "unsupported sequence type: ~s" seq-type)))))) 197 | ,code))) 198 | (%set-return-type :pointer) 199 | (setf (%get-state :dynarray-ret-length :err-val) err-val)))) 200 | 201 | (defmethod %error-condition (value (type (eql :dynarray))) 202 | `(eql ,value ,(%get-state :dynarray-ret-length :err-val))) 203 | 204 | (defmethod %special-retval-handling (name (key (eql :array)) &rest args) 205 | (destructuring-bind (type len &key (err-val :error) (free-array-p t)) args 206 | (unless (or (null len) (integerp len)) 207 | (error "length must be an integer or NIL")) 208 | (unless (constantp err-val) 209 | (error "error value must be constant")) 210 | (let ((g-i (gensym))) 211 | (%add-inner-wrapper 212 | #'(lambda (code) 213 | `(let ((,name (if (cffi:null-pointer-p ,name) 214 | ,err-val 215 | (loop for ,g-i from 0 216 | ,@(if len 217 | `(below ,len) 218 | `(until (cffi:null-pointer-p (cffi:mem-aref ,name :pointer ,g-i)))) 219 | collecting (cffi:mem-aref ,name ',type ,g-i) 220 | ,@(if free-array-p 221 | `(finally (relinquish-memory ,name))))))) 222 | ,code))) 223 | (%set-return-type :pointer) 224 | (setf (%get-state :ret-array :err-val) err-val)))) 225 | 226 | (defmethod %error-condition (value (type (eql :array))) 227 | `(eql ,value ,(%get-state :ret-array :err-val))) 228 | 229 | (defmacro defmagickfun (c-name ret-type args &key check-error (export-p t)) 230 | (let ((lisp-name (%magick-lisp-name c-name)) 231 | (simple-p (not check-error)) 232 | (error-type (and check-error (second (assoc check-error args)))) 233 | (retval (gensym)) 234 | internal-name 235 | (*outer-wrap-code* #'(lambda (code) code)) 236 | (*inner-wrap-code* #'(lambda (code) code)) 237 | (*ret-type* ret-type) 238 | *result-values* *defc-params* *lisp-params* *inv-params* *state*) 239 | (declare (special *outer-wrap-code* *inner-wrap-code* *ret-type* *result-values* 240 | *defc-params* *lisp-params* *inv-params* *state*)) 241 | (unless (or (eql ret-type :void) (and (eql ret-type :boolean) 242 | check-error)) 243 | (push retval *result-values*)) 244 | (dolist (arg args) 245 | (destructuring-bind (name type) arg 246 | (cond 247 | ((consp type) 248 | (setf simple-p nil) 249 | (apply #'%special-argument-handling name type)) 250 | (t 251 | (push arg *defc-params*) 252 | (push name *lisp-params*) 253 | (push name *inv-params*))))) 254 | 255 | (when (consp ret-type) 256 | (setf simple-p nil) 257 | (apply #'%special-retval-handling retval ret-type)) 258 | 259 | (unless simple-p 260 | (setf internal-name (%internal-fn-name lisp-name))) 261 | 262 | `(progn 263 | (cffi:defcfun (,c-name ,(or internal-name lisp-name)) ,*ret-type* ,@(reverse *defc-params*)) 264 | ,@ (unless simple-p 265 | `((defun ,lisp-name ,(reverse *lisp-params*) 266 | ,(funcall *outer-wrap-code* 267 | `(let ((,retval (,internal-name ,@(reverse *inv-params*)))) 268 | ,(funcall *inner-wrap-code* 269 | `(progn 270 | ,@ (when check-error 271 | `((when ,(%error-condition retval (if (consp ret-type) (car ret-type) ret-type)) 272 | ,(%error-signalling-code check-error error-type)))) 273 | (values ,@(reverse *result-values*))))))))) 274 | ,@ (when export-p `((export ',lisp-name)))))) 275 | 276 | 277 | (cffi:define-foreign-library lib-magick-wand 278 | (:darwin "libMagickWand.dylib") 279 | (:unix 280 | (:or 281 | "libMagickWand-7.Q16.so" 282 | "libMagickWand-7.Q16.so.2" 283 | "libMagickWand-7.Q16.so.3" 284 | "libMagickWand-7.Q16.so.4" 285 | "libMagickWand-7.Q16.so.5" 286 | "libMagickWand-7.Q16.so.6" 287 | "libMagickWand-7.Q16.so.7" 288 | "libMagickWand-7.Q16.so.8" 289 | 290 | "libMagickWand-7.Q16HDRI.so" 291 | "libMagickWand-7.Q16HDRI.so.2" 292 | "libMagickWand-7.Q16HDRI.so.3" 293 | "libMagickWand-7.Q16HDRI.so.4" 294 | "libMagickWand-7.Q16HDRI.so.5" 295 | "libMagickWand-7.Q16HDRI.so.6" 296 | "libMagickWand-7.Q16HDRI.so.7" 297 | "libMagickWand-7.Q16HDRI.so.8" 298 | "libMagickWand-7.Q16HDRI.so.9" 299 | "libMagickWand-7.Q16HDRI.so.10" 300 | 301 | "libMagickWand-6.Q16.so" 302 | "libMagickWand-6.Q16.so.2" 303 | "libMagickWand-6.Q16.so.3" 304 | "libMagickWand-6.Q16.so.4" 305 | "libMagickWand-6.Q16.so.5" 306 | "libMagickWand-6.Q16.so.6" 307 | "libMagickWand-6.Q16.so.7" 308 | "libMagickWand-6.Q16.so.8" 309 | 310 | "libMagickWand-6.Q16HDRI.so" 311 | "libMagickWand-6.Q16HDRI.so.2" 312 | "libMagickWand-6.Q16HDRI.so.3" 313 | "libMagickWand-6.Q16HDRI.so.4" 314 | "libMagickWand-6.Q16HDRI.so.5" 315 | "libMagickWand-6.Q16HDRI.so.6" 316 | "libMagickWand-6.Q16HDRI.so.7" 317 | "libMagickWand-6.Q16HDRI.so.8" 318 | 319 | "libMagickWand.so" 320 | "libWand.so.9" 321 | "libWand.so")) 322 | (t (:default "libWand"))) 323 | (cffi:use-foreign-library lib-magick-wand) 324 | 325 | (defun type-name-to-class-name (name) 326 | (intern (concatenate 'string (symbol-name name) "-TYPE-CLASS") 327 | (symbol-package name))) 328 | -------------------------------------------------------------------------------- /magick.lisp: -------------------------------------------------------------------------------- 1 | (in-package :lisp-magick-wand) 2 | 3 | ;;; Error handling 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | (define-condition magick-wand-error (error) 7 | ((message :initarg :message :reader magick-wand-error-message) 8 | (type :initarg :type :reader magick-wand-error-type)) 9 | (:report (lambda (c s) 10 | (format s "MagickWand Exception: ~a (~a)" 11 | (magick-wand-error-message c) 12 | (magick-wand-error-type c)))) 13 | (:documentation "Encapsulates errors reported by magick wand operations.")) 14 | 15 | (defun signal-magick-wand-error (wand) 16 | (multiple-value-bind (msg type) (get-exception wand) 17 | (error 'magick-wand-error :message msg :type type))) 18 | 19 | (defun signal-pixel-wand-error (wand) 20 | (multiple-value-bind (msg type) (pixel-get-exception wand) 21 | (error 'magick-wand-error :message msg :type type))) 22 | 23 | (defun signal-drawing-wand-error (wand) 24 | (multiple-value-bind (msg type) (draw-get-exception wand) 25 | (error 'magick-wand-error :message msg :type type))) 26 | 27 | 28 | (defmagickfun "MagickGetException" magick-string/free ((wand magick-wand) (exception (:out exception-type)))) 29 | (defmagickfun "PixelGetException" magick-string/free ((wand pixel-wand) (exception (:out exception-type)))) 30 | (defmagickfun "DrawGetException" magick-string/free ((wand drawing-wand) (exception (:out exception-type)))) 31 | 32 | (defmagickfun "MagickClearException" :boolean ((wand magick-wand))) 33 | (defmagickfun "PixelClearException" :boolean ((wand pixel-wand))) 34 | (defmagickfun "DrawClearException" :boolean ((wand drawing-wand))) 35 | 36 | 37 | ;;; ImageMagick Initialization / Termination / Information 38 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 39 | 40 | (defmagickfun "MagickWandGenesis" :void ()) 41 | (defmagickfun "MagickWandTerminus" :void ()) 42 | 43 | (defmagickfun "MagickGetHomeURL" magick-string/free ()) 44 | (defmagickfun "MagickQueryConfigureOption" magick-string/free ((option magick-string))) 45 | (defmagickfun "MagickQueryConfigureOptions" (:dynarray magick-string/free :err-val nil) 46 | ((pattern magick-string) (num (:dynarray-ret-length :ulong)))) 47 | (defmagickfun "MagickQueryFonts" (:dynarray magick-string/free :err-val nil) 48 | ((pattern magick-string) (num (:dynarray-ret-length :ulong)))) 49 | (defmagickfun "MagickQueryFormats" (:dynarray magick-string/free :err-val nil) 50 | ((pattern magick-string) (num (:dynarray-ret-length :ulong)))) 51 | (defmagickfun "MagickGetCopyright" magick-string ()) 52 | (defmagickfun "MagickGetPackageName" magick-string ()) 53 | (defmagickfun "MagickGetQuantumRange" magick-string ((range (:out :ulong)))) 54 | (defmagickfun "MagickGetReleaseDate" magick-string ()) 55 | (defmagickfun "MagickGetVersion" magick-string ((version (:out :ulong)))) 56 | 57 | (defmagickfun "MagickGetResource" :ulong ((type resource-type))) 58 | (defmagickfun "MagickGetResourceLimit" :ulong ((type resource-type))) 59 | (defmagickfun "MagickSetResourceLimit" :boolean ((type resource-type) (limit :ulong))) 60 | 61 | 62 | ;;; Magick Wands 63 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 64 | 65 | ;; Creation, destruction, etc. 66 | 67 | (defmagickfun "NewMagickWand" magick-wand ()) 68 | (defmagickfun "DestroyMagickWand" magick-wand ((wand magick-wand))) 69 | (defmagickfun "IsMagickWand" :boolean ((wand magick-wand))) 70 | (defmagickfun "CloneMagickWand" magick-wand ((wand magick-wand))) 71 | (defmagickfun "ClearMagickWand" :void ((wand magick-wand))) 72 | (defmagickfun "MagickCoalesceImages" magick-wand ((wand magick-wand))) 73 | (defmagickfun "MagickCombineImages" magick-wand ((wand magick-wand) (colorspace colorspace-type))) 74 | (defmagickfun "MagickCompareImagesLayers" magick-wand ((wand magick-wand) (method layer-method))) 75 | (defmagickfun "MagickCompareImages" magick-wand ((wand magick-wand) (metric metric-type) (distortion magick-double))) 76 | (defmagickfun "MagickComplexImages" magick-wand ((wand magick-wand) (complex complex-operator))) 77 | (defmagickfun "MagickDeconstructImages" magick-wand ((wand magick-wand))) 78 | (defmagickfun "MagickFxImage" magick-wand ((wand magick-wand) (expression magick-string))) 79 | (defmagickfun "MagickGetImage" magick-wand ((wand magick-wand))) 80 | (defmagickfun "MagickGetImageMask" magick-wand ((wand magick-wand) (type pixel-mask))) 81 | (defmagickfun "MagickGetImageRegion" magick-wand ((wand magick-wand) (width :ulong) (height :ulong) (x :long) (y :long))) 82 | (defmagickfun "MagickMergeImageLayers" magick-wand ((wand magick-wand) (method layer-method))) 83 | (defmagickfun "MagickMontageImage" magick-wand ((wand magick-wand) (drawing-wand drawing-wand) (tile-geometry magick-string) 84 | (thumbnail-geometry magick-string) (mode montage-mode))) 85 | (defmagickfun "MagickMorphImages" magick-wand ((wand magick-wand) (number-frames :ulong))) 86 | (defmagickfun "MagickOptimizeImageLayers" magick-wand ((wand magick-wand))) 87 | (defmagickfun "MagickPreviewImages" magick-wand ((wand magick-wand) (preview preview-type))) 88 | (defmagickfun "MagickSmushImages" magick-wand ((wand magick-wand) (stack :boolean) (offset :long))) 89 | (defmagickfun "MagickSteganoImage" magick-wand ((wand magick-wand) (watermark-wand magick-wand) (offset :long))) 90 | (defmagickfun "MagickStereoImage" magick-wand ((wand magick-wand) (offset-wand magick-wand))) 91 | (defmagickfun "MagickTextureImage" magick-wand ((wand magick-wand) (texture-wand magick-wand))) 92 | 93 | 94 | ;; Image Iterator 95 | 96 | (defmagickfun "MagickResetIterator" :void ((wand magick-wand))) 97 | (defmagickfun "MagickSetFirstIterator" :void ((wand magick-wand))) 98 | (defmagickfun "MagickSetIteratorIndex" :boolean ((wand magick-wand) (index :long))) 99 | (defmagickfun "MagickSetLastIterator" :void ((wand magick-wand))) 100 | (defmagickfun "MagickHasNextImage" :boolean ((wand magick-wand))) 101 | (defmagickfun "MagickHasPreviousImage" :boolean ((wand magick-wand))) 102 | (defmagickfun "MagickNextImage" :boolean ((wand magick-wand))) 103 | (defmagickfun "MagickPreviousImage" :boolean ((wand magick-wand))) 104 | 105 | 106 | ;; Attributes 107 | 108 | (defmagickfun "MagickGetFilename" magick-string/free ((wand magick-wand))) 109 | (defmagickfun "MagickGetFormat" magick-string/free ((wand magick-wand))) 110 | (defmagickfun "MagickGetOption" magick-string/free ((wand magick-wand) (key magick-string))) 111 | (defmagickfun "MagickGetCompression" compression-type ((wand magick-wand))) 112 | (defmagickfun "MagickGetSamplingFactors" (:dynarray :double :err-val nil) 113 | ((wand magick-wand) (num (:dynarray-ret-length :ulong)))) 114 | (defmagickfun "MagickQueryFontMetrics" (:array :double 7) 115 | ((wand magick-wand) (dwand drawing-wand) (text magick-string)) 116 | :check-error wand) 117 | (defmagickfun "MagickQueryMultilineFontMetrics" (:array :double 7) 118 | ((wand magick-wand) (dwand drawing-wand) (text magick-string)) 119 | :check-error wand) 120 | (defmagickfun "MagickGetInterlaceScheme" interlace-type ((wand magick-wand))) 121 | (defmagickfun "MagickGetPage" :boolean 122 | ((wand magick-wand) (width (:out :ulong)) (height (:out :ulong)) (x (:out :long)) (y (:out :long))) 123 | :check-error wand) 124 | (defmagickfun "MagickGetSize" :boolean 125 | ((wand magick-wand) (columns (:out :ulong)) (rows (:out :ulong))) 126 | :check-error wand) 127 | (defmagickfun "MagickGetCompressionQuality" :ulong ((wand magick-wand))) 128 | 129 | (defmagickfun "MagickSetBackgroundColor" :boolean ((wand magick-wand) (background pixel-wand)) :check-error wand) 130 | (defmagickfun "MagickSetCompression" :boolean ((wand magick-wand) (compression compression-type)) :check-error wand) 131 | (defmagickfun "MagickSetCompressionQuality" :boolean ((wand magick-wand) (quality :ulong)) :check-error wand) 132 | (defmagickfun "MagickSetFilename" :boolean ((wand magick-wand) (filename magick-string)) :check-error wand) 133 | (defmagickfun "MagickSetFont" :boolean ((wand magick-wand) (format magick-string)) :check-error wand) 134 | (defmagickfun "MagickSetFormat" :boolean ((wand magick-wand) (font magick-string)) :check-error wand) 135 | (defmagickfun "MagickSetInterlaceScheme" :boolean ((wand magick-wand) (interlace-scheme interlace-type)) :check-error wand) 136 | (defmagickfun "MagickSetOption" :boolean ((wand magick-wand) (key magick-string) 137 | (value magick-string)) :check-error wand) 138 | (defmagickfun "MagickSetPage" :boolean ((wand magick-wand) (width :ulong) (height :ulong) 139 | (x :long) (y :long)) :check-error wand) 140 | (defmagickfun "MagickSetPassphrase" :boolean ((wand magick-wand) (passphrase magick-string)) :check-error wand) 141 | (defmagickfun "MagickSetPointsize" :boolean ((wand magick-wand) (pointsize magick-double)) :check-error wand) 142 | (defmagickfun "MagickSetResolution" :boolean ((wand magick-wand) (x-resolution magick-double) 143 | (y-resolution magick-double)) :check-error wand) 144 | (defmagickfun "MagickSetSamplingFactors" :boolean ((wand magick-wand) (num (:dynarray-length :ulong factors)) 145 | (factors (:dynarray magick-double))) :check-error wand) 146 | (defmagickfun "MagickSetSize" :boolean ((wand magick-wand) (columns :ulong) (rows :ulong)) :check-error wand) 147 | (defmagickfun "MagickSetType" :boolean ((wand magick-wand) (type image-type)) :check-error wand) 148 | 149 | 150 | ;; Image get params 151 | (defmagickfun "MagickGetImageAlphaChannel" :boolean 152 | ((wand magick-wand))) 153 | (defmagickfun "MagickGetImageBackgroundColor" :boolean 154 | ((wand magick-wand) (color pixel-wand)) 155 | :check-error wand) 156 | (defmagickfun "MagickGetImageBluePrimary" :boolean 157 | ((wand magick-wand) (x (:out :double)) (y (:out :double))) 158 | :check-error wand) 159 | (defmagickfun "MagickGetImageBorderColor" :boolean 160 | ((wand magick-wand) (color pixel-wand)) 161 | :check-error wand) 162 | (defmagickfun "MagickGetImageKurtosis" :boolean 163 | ((wand magick-wand) (kurtosis (:out :double)) (skewness (:out :double))) 164 | :check-error wand) 165 | (defmagickfun "MagickGetImageMean" :boolean 166 | ((wand magick-wand) (mean (:out :double)) (standard-deviation (:out :double))) 167 | :check-error wand) 168 | (defmagickfun "MagickGetImageRange" :boolean 169 | ((wand magick-wand) (minima (:out :double)) (maxima (:out :double))) 170 | :check-error wand) 171 | (defmagickfun "MagickGetImageColormapColor" :boolean 172 | ((wand magick-wand) (index :ulong) (color pixel-wand)) 173 | :check-error wand) 174 | (defmagickfun "MagickGetImageColors" :ulong 175 | ((wand magick-wand))) 176 | (defmagickfun "MagickGetImageColorspace" colorspace-type 177 | ((wand magick-wand))) 178 | (defmagickfun "MagickGetImageCompose" composite-operator 179 | ((wand magick-wand))) 180 | (defmagickfun "MagickGetImageCompression" compression-type 181 | ((wand magick-wand))) 182 | (defmagickfun "MagickGetImageCompressionQuality" :ulong 183 | ((wand magick-wand))) 184 | (defmagickfun "MagickGetImageDelay" :ulong 185 | ((wand magick-wand))) 186 | (defmagickfun "MagickGetImageDepth" :ulong 187 | ((wand magick-wand))) 188 | (defmagickfun "MagickGetImageDispose" dispose-type 189 | ((wand magick-wand))) 190 | (defmagickfun "MagickGetImageDistortion" :boolean 191 | ((wand magick-wand) (reference magick-wand) 192 | (metric metric-type) (distortion (:out :double))) 193 | :check-error wand) 194 | (defmagickfun "MagickGetImageDistortions" :double 195 | ((wand magick-wand) (reference magick-wand)(metric metric-type))) 196 | (defmagickfun "MagickGetImageEndian" endian-type 197 | ((wand magick-wand))) 198 | (defmagickfun "MagickGetImageFilename" magick-string/free 199 | ((wand magick-wand)) 200 | :check-error wand) 201 | (defmagickfun "MagickGetImageFilter" filter-type 202 | ((wand magick-wand))) 203 | (defmagickfun "MagickGetImageFormat" magick-string/free 204 | ((wand magick-wand)) 205 | :check-error wand) 206 | (defmagickfun "MagickGetImageFuzz" :double 207 | ((wand magick-wand))) 208 | (defmagickfun "MagickGetImageGamma" :double 209 | ((wand magick-wand))) 210 | (defmagickfun "MagickGetImageGravity" gravity-type 211 | ((wand magick-wand))) 212 | (defmagickfun "MagickGetImageGreenPrimary" :boolean 213 | ((wand magick-wand) (x (:out :double)) (y (:out :double))) 214 | :check-error wand) 215 | (defmagickfun "MagickGetImageHeight" :ulong 216 | ((wand magick-wand))) 217 | (defmagickfun "MagickGetImageInterlaceScheme" interlace-type 218 | ((wand magick-wand))) 219 | (defmagickfun "MagickGetImageInterpolateMethod" pixel-interpolate-method 220 | ((wand magick-wand))) 221 | (defmagickfun "MagickGetImageIterations" :ulong 222 | ((wand magick-wand))) 223 | (defmagickfun "MagickGetImageLength" :boolean 224 | ((wand magick-wand) (x (:out :ulong))) 225 | :check-error wand) 226 | (defmagickfun "MagickGetImageMatteColor" :boolean 227 | ((wand magick-wand) (color pixel-wand)) 228 | :check-error wand) 229 | (defmagickfun "MagickGetImageOrientation" orientation-type 230 | ((wand magick-wand))) 231 | (defmagickfun "MagickGetImagePage" :boolean 232 | ((wand magick-wand) (width (:out :ulong)) (height (:out :ulong)) 233 | (x (:out :long)) (y (:out :long))) 234 | :check-error wand) 235 | (defmagickfun "MagickGetImagePixelColor" :boolean 236 | ((wand magick-wand) (x :long) (y :long) (color pixel-wand)) 237 | :check-error wand) 238 | (defmagickfun "MagickGetImageRedPrimary" :boolean 239 | ((wand magick-wand) (x (:out :double)) (y (:out :double))) 240 | :check-error wand) 241 | (defmagickfun "MagickGetImageRenderingIntent" rendering-intent 242 | ((wand magick-wand))) 243 | (defmagickfun "MagickGetImageResolution" :boolean 244 | ((wand magick-wand) (x (:out :double))(y (:out :double))) 245 | :check-error wand) 246 | (defmagickfun "MagickGetImageScene" :ulong 247 | ((wand magick-wand))) 248 | (defmagickfun "MagickGetImageSignature" magick-string/free 249 | ((wand magick-wand)) 250 | :check-error wand) 251 | (defmagickfun "MagickGetImageTicksPerSecond" :ulong 252 | ((wand magick-wand))) 253 | (defmagickfun "MagickGetImageType" image-type 254 | ((wand magick-wand))) 255 | (defmagickfun "MagickGetImageVirtualPixelMethod" virtual-pixel-method 256 | ((wand magick-wand))) 257 | (defmagickfun "MagickGetImageWhitePoint" :boolean 258 | ((wand magick-wand) (x (:out :double)) (y (:out :double))) 259 | :check-error wand) 260 | (defmagickfun "MagickGetImageWidth" :ulong 261 | ((wand magick-wand))) 262 | (defmagickfun "MagickGetNumberImages" :ulong 263 | ((wand magick-wand))) 264 | (defmagickfun "MagickGetImageTotalInkDensity" :double 265 | ((wand magick-wand))) 266 | (defmagickfun "MagickIdentifyImage" magick-string/free 267 | ((wand magick-wand)) 268 | :check-error wand) 269 | ;; deprecated 270 | (defmagickfun "MagickGetImageAttribute" magick-string/free 271 | ((wand magick-wand) (key magick-string))) 272 | ;; deprecated 273 | (defmagickfun "MagickGetImageIndex" :long 274 | ((wand magick-wand))) 275 | ;; deprecated 276 | (defmagickfun "MagickGetImageMatte" :boolean 277 | ((wand magick-wand))) 278 | ;; deprecated 279 | (defmagickfun "MagickGetImageChannelDistortion" :boolean 280 | ((wand magick-wand) (reference magick-wand) (channel channel-type) 281 | (metric metric-type) (distortion (:out :double))) 282 | :check-error wand) 283 | ;; deprecated 284 | (defmagickfun "MagickGetImageChannelExtrema" :boolean 285 | ((wand magick-wand) (channel channel-type) 286 | (min (:out :ulong)) (max (:out :ulong))) 287 | :check-error wand) 288 | ;; deprecated 289 | (defmagickfun "MagickGetImageChannelMean" :boolean 290 | ((wand magick-wand) (channel channel-type) 291 | (mean (:out :double)) (std-dev (:out :double))) 292 | :check-error wand) 293 | ;; deprecated 294 | (defmagickfun "MagickGetImageExtrema" :boolean 295 | ((wand magick-wand) 296 | (min (:out :ulong)) (max (:out :ulong))) 297 | :check-error wand) 298 | 299 | ;; Image set params 300 | (defmagickfun "MagickSetImageAlphaChannel" :boolean 301 | ((wand magick-wand) (alpha-type alpha-channel-type)) 302 | :check-error wand) 303 | (defmagickfun "MagickSetImageBackgroundColor" :boolean 304 | ((wand magick-wand) (background pixel-wand)) 305 | :check-error wand) 306 | (defmagickfun "MagickSetImageBluePrimary" :boolean 307 | ((wand magick-wand) (x magick-double) (y magick-double) (z magick-double)) 308 | :check-error wand) 309 | (defmagickfun "MagickSetImageBorderColor" :boolean 310 | ((wand magick-wand) (border pixel-wand)) 311 | :check-error wand) 312 | (defmagickfun "MagickSetImageChannelMask" :boolean 313 | ((wand magick-wand) (channel-mask channel-type)) 314 | :check-error wand) 315 | (defmagickfun "MagickSetImageColor" :boolean 316 | ((wand magick-wand) (color pixel-wand)) 317 | :check-error wand) 318 | (defmagickfun "MagickSetImageColormapColor" :boolean 319 | ((wand magick-wand) (index :ulong) (color pixel-wand)) 320 | :check-error wand) 321 | (defmagickfun "MagickSetImageColorspace" :boolean 322 | ((wand magick-wand) (colorspace colorspace-type)) 323 | :check-error wand) 324 | (defmagickfun "MagickSetImageCompose" :boolean 325 | ((wand magick-wand) (compose composite-operator)) 326 | :check-error wand) 327 | (defmagickfun "MagickSetImageCompression" :boolean 328 | ((wand magick-wand) (compression compression-type)) 329 | :check-error wand) 330 | (defmagickfun "MagickSetImageCompressionQuality" :boolean 331 | ((wand magick-wand) (quality :ulong)) 332 | :check-error wand) 333 | (defmagickfun "MagickSetImageDelay" :boolean 334 | ((wand magick-wand) (delay :ulong)) 335 | :check-error wand) 336 | (defmagickfun "MagickSetImageDepth" :boolean 337 | ((wand magick-wand) (depth :ulong)) 338 | :check-error wand) 339 | (defmagickfun "MagickSetImageDispose" :boolean 340 | ((wand magick-wand) (dispose dispose-type)) 341 | :check-error wand) 342 | (defmagickfun "MagickSetImageEndian" :boolean 343 | ((wand magick-wand) (endian endian-type)) 344 | :check-error wand) 345 | (defmagickfun "MagickSetImageExtent" :boolean 346 | ((wand magick-wand) (columns :ulong) (rows :ulong)) 347 | :check-error wand) 348 | (defmagickfun "MagickSetImageFilename" :boolean 349 | ((wand magick-wand) (filename magick-string)) 350 | :check-error wand) 351 | (defmagickfun "MagickSetImageFilter" :boolean 352 | ((wand magick-wand) (filter filter-type)) 353 | :check-error wand) 354 | (defmagickfun "MagickSetImageFormat" :boolean 355 | ((wand magick-wand) (format magick-string)) 356 | :check-error wand) 357 | (defmagickfun "MagickSetImageFuzz" :boolean 358 | ((wand magick-wand) (fuzz magick-double)) 359 | :check-error wand) 360 | (defmagickfun "MagickSetImageGamma" :boolean 361 | ((wand magick-wand) (gamma magick-double)) 362 | :check-error wand) 363 | (defmagickfun "MagickSetImageGravity" :boolean 364 | ((wand magick-wand) (gravity gravity-type)) 365 | :check-error wand) 366 | (defmagickfun "MagickSetImageGreenPrimary" :boolean 367 | ((wand magick-wand) (x magick-double) (y magick-double) (z magick-double)) 368 | :check-error wand) 369 | (defmagickfun "MagickSetImageInterlaceScheme" :boolean 370 | ((wand magick-wand) (interlace interlace-type)) 371 | :check-error wand) 372 | (defmagickfun "MagickSetImageInterpolateMethod" :boolean 373 | ((wand magick-wand) (method pixel-interpolate-method)) 374 | :check-error wand) 375 | (defmagickfun "MagickSetImageIterations" :boolean 376 | ((wand magick-wand) (iterations :ulong)) 377 | :check-error wand) 378 | (defmagickfun "MagickSetImageMatteColor" :boolean 379 | ((wand magick-wand) (matte pixel-wand)) 380 | :check-error wand) 381 | (defmagickfun "MagickSetImageAlpha" :boolean 382 | ((wand magick-wand) (alpha magick-double)) 383 | :check-error wand) 384 | (defmagickfun "MagickSetImageOrientation" :boolean 385 | ((wand magick-wand) (orientation orientation-type)) 386 | :check-error wand) 387 | (defmagickfun "MagickSetImagePage" :boolean 388 | ((wand magick-wand) (width :ulong) (height :ulong) (x :long) (y :long)) 389 | :check-error wand) 390 | (defmagickfun "MagickSetImagePixelColor" :boolean 391 | ((wand magick-wand) (x :long) (y :long) (color pixel-wand)) 392 | :check-error wand) 393 | (defmagickfun "MagickSetImageRedPrimary" :boolean 394 | ((wand magick-wand) (x magick-double) (y magick-double) (z magick-double)) 395 | :check-error wand) 396 | (defmagickfun "MagickSetImageRenderingIntent" :boolean 397 | ((wand magick-wand) (rendering-intent rendering-intent)) 398 | :check-error wand) 399 | (defmagickfun "MagickSetImageResolution" :boolean 400 | ((wand magick-wand) (x-resolution magick-double) (y-resolution magick-double)) 401 | :check-error wand) 402 | (defmagickfun "MagickSetImageScene" :boolean 403 | ((wand magick-wand) (scene :ulong)) 404 | :check-error wand) 405 | (defmagickfun "MagickSetImageTicksPerSecond" :boolean 406 | ((wand magick-wand) (ticks :ulong)) 407 | :check-error wand) 408 | (defmagickfun "MagickSetImageType" :boolean 409 | ((wand magick-wand) (image-type image-type)) 410 | :check-error wand) 411 | (defmagickfun "MagickSetImageVirtualPixelMethod" :boolean 412 | ((wand magick-wand) (method virtual-pixel-method)) 413 | :check-error wand) 414 | (defmagickfun "MagickSetImageWhitePoint" :boolean 415 | ((wand magick-wand) (x magick-double) (y magick-double) (z magick-double)) 416 | :check-error wand) 417 | 418 | 419 | ;; Create/Read/write/remove images 420 | 421 | (defmagickfun "MagickNewImage" :boolean 422 | ((wand magick-wand) (width :ulong) (height :ulong) (background pixel-wand)) 423 | :check-error wand) 424 | (defmagickfun "MagickPingImage" :boolean 425 | ((wand magick-wand) (filename magick-string)) 426 | :check-error wand) 427 | (defmagickfun "MagickPingImageBlob" :boolean 428 | ((wand magick-wand) 429 | (blob (:dynarray :uint8)) 430 | (length (:dynarray-length size-t blob))) 431 | :check-error wand) 432 | (defmagickfun "MagickReadImage" :boolean 433 | ((wand magick-wand) (filename magick-string)) 434 | :check-error wand) 435 | (defmagickfun "MagickReadImageBlob" :boolean 436 | ((wand magick-wand) 437 | (blob (:dynarray :uint8)) 438 | (length (:dynarray-length size-t blob))) 439 | :check-error wand) 440 | (defmagickfun "MagickGetImageBlob" (:dynarray :uint8 :seq-type (vector (unsigned-byte 8))) 441 | ((wand magick-wand) 442 | (len (:dynarray-ret-length :ulong))) 443 | :check-error wand) 444 | (defmagickfun "MagickRemoveImage" :boolean 445 | ((wand magick-wand)) 446 | :check-error wand) 447 | (defmagickfun "MagickSetImage" :boolean 448 | ((wand magick-wand) (set-wand magick-wand)) 449 | :check-error wand) 450 | (defmagickfun "MagickWriteImage" :boolean 451 | ((wand magick-wand) (filename magick-string)) 452 | :check-error wand) 453 | (defmagickfun "MagickWriteImages" :boolean 454 | ((wand magick-wand) (filename magick-string) (adjoin_ :boolean)) 455 | :check-error wand) 456 | 457 | 458 | ;; Get/set pixel data 459 | 460 | ;; deprecated 461 | (defmagickfun "MagickGetImagePixels" :boolean 462 | ((wand magick-wand) (x :long) (y :long) (columns :ulong) (rows :ulong) 463 | (map magick-string) (storage storage-type) (pixels :pointer)) 464 | :check-error wand) 465 | ;;; not deprecated 466 | (defmagickfun "MagickExportImagePixels" :boolean 467 | ((wand magick-wand) (x :long) (y :long) (columns :ulong) (rows :ulong) 468 | (map magick-string) (storage storage-type) (pixels :pointer)) 469 | :check-error wand) 470 | ;; deprecated 471 | (defmagickfun "MagickSetImagePixels" :boolean 472 | ((wand magick-wand) (x :long) (y :long) (columns :ulong) (rows :ulong) 473 | (map magick-string) (storage storage-type) (pixels :pointer)) 474 | :check-error wand) 475 | ;;; not deprecated 476 | (defmagickfun "MagickImportImagePixels" :boolean 477 | ((wand magick-wand) (x :long) (y :long) (columns :ulong) (rows :ulong) 478 | (map magick-string) (storage storage-type) (pixels :pointer)) 479 | :check-error wand) 480 | 481 | 482 | ;; Image operations 483 | 484 | (defmagickfun "MagickAdaptiveResizeImage" :boolean 485 | ((wand magick-wand) (columns :ulong) (rows :ulong)) 486 | :check-error wand) 487 | (defmagickfun "MagickAdaptiveSharpenImage" :boolean 488 | ((wand magick-wand) (radius magick-double) (sigma magick-double)) 489 | :check-error wand) 490 | (defmagickfun "MagickAdaptiveThresholdImage" :boolean 491 | ((wand magick-wand) (width :ulong) (height :ulong) (offset :long)) 492 | :check-error wand) 493 | (defmagickfun "MagickAddImage" :boolean 494 | ((wand magick-wand) (add-wand magick-wand)) 495 | :check-error wand) 496 | (defmagickfun "MagickAddNoiseImage" :boolean 497 | ((wand magick-wand) (type noise-type)) 498 | :check-error wand) 499 | (defmagickfun "MagickAffineTransformImage" :boolean 500 | ((wand magick-wand) (dwand drawing-wand)) 501 | :check-error wand) 502 | (defmagickfun "MagickAnnotateImage" :boolean 503 | ((wand magick-wand) (dwand drawing-wand) 504 | (x magick-double) (y magick-double) (angle magick-double) (text magick-string)) 505 | :check-error wand) 506 | (defmagickfun "MagickAnimateImages" :boolean 507 | ((wand magick-wand) (server-name magick-string)) 508 | :check-error wand) 509 | (defmagickfun "MagickAutoGammaImage" :boolean 510 | ((wand magick-wand)) 511 | :check-error wand) 512 | (defmagickfun "MagickAutoLevelImage" :boolean 513 | ((wand magick-wand)) 514 | :check-error wand) 515 | (defmagickfun "MagickAutoOrientImage" :boolean 516 | ((wand magick-wand)) 517 | :check-error wand) 518 | (defmagickfun "MagickAutoThresholdImage" :boolean 519 | ((wand magick-wand) (method auto-threshold-method)) 520 | :check-error wand) 521 | (defmagickfun "MagickBilateralBlurImage" :boolean 522 | ((wand magick-wand) (radius magick-double) (sigma magick-double) 523 | (intensity-sigma magick-double) (spatial-sigma magick-double)) 524 | :check-error wand) 525 | (defmagickfun "MagickBlackThresholdImage" :boolean 526 | ((wand magick-wand) (threshold pixel-wand)) 527 | :check-error wand) 528 | (defmagickfun "MagickBlueShiftImage" :boolean 529 | ((wand magick-wand) (factor magick-double)) 530 | :check-error wand) 531 | (defmagickfun "MagickBlurImage" :boolean 532 | ((wand magick-wand) (radius magick-double) (sigma magick-double)) 533 | :check-error wand) 534 | (defmagickfun "MagickBlurImageChannel" :boolean 535 | ((wand magick-wand) (channel channel-type) (radius magick-double) (sigma magick-double)) 536 | :check-error wand) 537 | (defmagickfun "MagickBorderImage" :boolean 538 | ((wand magick-wand) (color pixel-wand) (width :ulong) (height :ulong)) 539 | :check-error wand) 540 | (defmagickfun "MagickBrightnessContrastImage" :boolean 541 | ((wand magick-wand) (brightness magick-double) (contrast magick-double)) 542 | :check-error wand) 543 | (defmagickfun "MagickCannyEdgeImage" :boolean 544 | ((wand magick-wand) (radius magick-double) (sigma magick-double) 545 | (lower-percent magick-double) (upper-percent magick-double)) 546 | :check-error wand) 547 | (defmagickfun "MagickCharcoalImage" :boolean 548 | ((wand magick-wand) (radius magick-double) (sigma magick-double)) 549 | :check-error wand) 550 | (defmagickfun "MagickChopImage" :boolean 551 | ((wand magick-wand) (width :ulong) (height :ulong) (x :long) (y :long)) 552 | :check-error wand) 553 | (defmagickfun "MagickCLAHEImage" :boolean 554 | ((wand magick-wand) (width :ulong) (height :ulong) 555 | (number-bins magick-double) (clip-limit magick-double)) 556 | :check-error wand) 557 | (defmagickfun "MagickClampImage" :boolean 558 | ((wand magick-wand)) 559 | :check-error wand) 560 | ;; deprecated 561 | (defmagickfun "MagickClipImage" :boolean 562 | ((wand magick-wand)) 563 | :check-error wand) 564 | ;; deprecated 565 | (defmagickfun "MagickClipPathImage" :boolean 566 | ((wand magick-wand) (path-name magick-string) (inside :boolean)) 567 | :check-error wand) 568 | ;; deprecated 569 | (defmagickfun "MagickColorFloodfillImage" :boolean 570 | ((wand magick-wand) (fill pixel-wand) (fuzz magick-double) 571 | (border-color pixel-wand) (x :long) (y :long)) 572 | :check-error wand) 573 | (defmagickfun "MagickColorizeImage" :boolean 574 | ((wand magick-wand) (colorize pixel-wand) (opacity pixel-wand)) 575 | :check-error wand) 576 | (defmagickfun "MagickColorThresholdImage" :boolean 577 | ((wand magick-wand) (start-color pixel-wand) (stop-color pixel-wand)) 578 | :check-error wand) 579 | (defmagickfun "MagickCommentImage" :boolean 580 | ((wand magick-wand) (comment magick-string)) 581 | :check-error wand) 582 | (defmagickfun "MagickCompositeImage" :boolean 583 | ((wand magick-wand) (src magick-wand) (compose composite-operator) (clip-to-self :boolean) 584 | (x :long) (y :long)) 585 | :check-error wand) 586 | (defmagickfun "MagickCompositeLayers" :boolean 587 | ((wand magick-wand) (src magick-wand) (compose composite-operator) 588 | (x :long) (y :long)) 589 | :check-error wand) 590 | (defmagickfun "MagickConstituteImage" :boolean 591 | ((wand magick-wand) (columns :ulong) (rows :ulong) (map magick-string) 592 | (storage storage-type) (pixels :pointer)) 593 | :check-error wand) 594 | (defmagickfun "MagickContrastImage" :boolean 595 | ((wand magick-wand) (sharpen :boolean)) 596 | :check-error wand) 597 | (defmagickfun "MagickConvolveImage" :boolean 598 | ((wand magick-wand) 599 | (order (:dynarray-length :ulong kernel :expr (isqrt :l))) 600 | (kernel (:dynarray magick-double))) 601 | :check-error wand) 602 | (defmagickfun "MagickConvolveImageChannel" :boolean 603 | ((wand magick-wand) 604 | (channel channel-type) 605 | (order (:dynarray-length :ulong kernel :expr (isqrt :l))) 606 | (kernel (:dynarray magick-double))) 607 | :check-error wand) 608 | 609 | (defmagickfun "MagickContrastStretchImage" :boolean 610 | ((wand magick-wand) (black-point magick-double) (white-point magick-double)) 611 | :check-error wand) 612 | (defmagickfun "MagickCropImage" :boolean 613 | ((wand magick-wand) (width :ulong) (height :ulong) (x :long) (y :long)) 614 | :check-error wand) 615 | (defmagickfun "MagickCycleColormapImage" :boolean 616 | ((wand magick-wand) (displace :long)) 617 | :check-error wand) 618 | (defmagickfun "MagickDecipherImage" :boolean 619 | ((wand magick-wand) (passphrase magick-string)) 620 | :check-error wand) 621 | (defmagickfun "MagickDeskewImage" :boolean 622 | ((wand magick-wand) (threshold pixel-wand)) 623 | :check-error wand) 624 | (defmagickfun "MagickDespeckleImage" :boolean 625 | ((wand magick-wand)) 626 | :check-error wand) 627 | (defmagickfun "MagickDisplayImage" :boolean 628 | ((wand magick-wand) (server-name magick-string)) 629 | :check-error wand) 630 | (defmagickfun "MagickDisplayImages" :boolean 631 | ((wand magick-wand) (server-name magick-string)) 632 | :check-error wand) 633 | (defmagickfun "MagickDistortImage" :boolean 634 | ((wand magick-wand) (method distort-method) 635 | (num-args (:dynarray-length :ulong args)) 636 | (args (:dynarray magick-double)) 637 | (best-fit :boolean)) 638 | :check-error wand) 639 | (defmagickfun "MagickDrawImage" :boolean 640 | ((wand magick-wand) (dwand drawing-wand)) 641 | :check-error wand) 642 | (defmagickfun "MagickEdgeImage" :boolean 643 | ((wand magick-wand) (radius magick-double)) 644 | :check-error wand) 645 | (defmagickfun "MagickEmbossImage" :boolean 646 | ((wand magick-wand) (radius magick-double) (sigma magick-double)) 647 | :check-error wand) 648 | (defmagickfun "MagickEncipherImage" :boolean 649 | ((wand magick-wand) (passphrase magick-string)) 650 | :check-error wand) 651 | (defmagickfun "MagickEnhanceImage" :boolean 652 | ((wand magick-wand)) 653 | :check-error wand) 654 | (defmagickfun "MagickEqualizeImage" :boolean 655 | ((wand magick-wand)) 656 | :check-error wand) 657 | (defmagickfun "MagickEvaluateImage" :boolean 658 | ((wand magick-wand) (op magick-evaluate-operator) (constant magick-double)) 659 | :check-error wand) 660 | (defmagickfun "MagickEvaluateImageChannel" :boolean 661 | ((wand magick-wand) (channel channel-type) 662 | (op magick-evaluate-operator) (constant magick-double)) 663 | :check-error wand) 664 | (defmagickfun "MagickExtentImage" :boolean 665 | ((wand magick-wand) (width :ulong) (height :ulong) (x :long) (y :long)) 666 | :check-error wand) 667 | (defmagickfun "MagickFlipImage" :boolean 668 | ((wand magick-wand)) 669 | :check-error wand) 670 | (defmagickfun "MagickFloodfillPaintImage" :boolean 671 | ((wand magick-wand) (fill pixel-wand) (fuzz magick-double) 672 | (border-color pixel-wand) (x :long) (y :long) (invert :boolean)) 673 | :check-error wand) 674 | (defmagickfun "MagickFlopImage" :boolean 675 | ((wand magick-wand)) 676 | :check-error wand) 677 | (defmagickfun "MagickForwardFourierTransformImage" :boolean 678 | ((wand magick-wand) (magnitude :boolean)) 679 | :check-error wand) 680 | (defmagickfun "MagickFrameImage" :boolean 681 | ((wand magick-wand) (matte-color pixel-wand) 682 | (width :ulong) (height :ulong) (inner-bevel :long) (outer-bevel :long)) 683 | :check-error wand) 684 | (defmagickfun "MagickGammaImage" :boolean 685 | ((wand magick-wand) (gamme magick-double)) 686 | :check-error wand) 687 | (defmagickfun "MagickGammaImageChannel" :boolean 688 | ((wand magick-wand) (channel channel-type) (gamme magick-double)) 689 | :check-error wand) 690 | (defmagickfun "MagickGaussianBlurImage" :boolean 691 | ((wand magick-wand) (radius magick-double) (sigma magick-double)) 692 | :check-error wand) 693 | (defmagickfun "MagickGaussianBlurImageChannel" :boolean 694 | ((wand magick-wand) (channel channel-type) (radius magick-double) (sigma magick-double)) 695 | :check-error wand) 696 | (defmagickfun "MagickHaldClutImage" :boolean 697 | ((wand magick-wand) (hald-wand magick-wand)) 698 | :check-error wand) 699 | (defmagickfun "MagickHoughLineImage" :boolean 700 | ((wand magick-wand) (width :ulong) (height :ulong) (threshold :long)) 701 | :check-error wand) 702 | (defmagickfun "MagickImplodeImage" :boolean 703 | ((wand magick-wand) (amount magick-double)) 704 | :check-error wand) 705 | (defmagickfun "MagickInterpolativeResizeImage" :boolean 706 | ((wand magick-wand) (columns :ulong) (rows :ulong) (method pixel-interpolate-method)) 707 | :check-error wand) 708 | (defmagickfun "MagickInverseFourierTransformImage" :boolean 709 | ((magnitude-wand magick-wand) (phase-wand magick-wand) (magnitude :boolean)) 710 | :check-error magnitude-wand) 711 | (defmagickfun "MagickKmeansImage" :boolean 712 | ((wand magick-wand) (number-colors :ulong) (max-iterations :ulong) (tolerance magick-double)) 713 | :check-error wand) 714 | (defmagickfun "MagickKuwaharaImage" :boolean 715 | ((wand magick-wand) (radius magick-double) (sigma magick-double)) 716 | :check-error wand) 717 | (defmagickfun "MagickLabelImage" :boolean 718 | ((wand magick-wand) (label magick-string)) 719 | :check-error wand) 720 | (defmagickfun "MagickLevelImage" :boolean 721 | ((wand magick-wand) (black-point magick-double) (gamma magick-double) 722 | (white-point magick-double)) 723 | :check-error wand) 724 | (defmagickfun "MagickLevelImageChannel" :boolean 725 | ((wand magick-wand) (channel channel-type) 726 | (black-point magick-double) (gamma magick-double) 727 | (white-point magick-double)) 728 | :check-error wand) 729 | (defmagickfun "MagickLevelImageColors" :boolean 730 | ((wand magick-wand) (black-color pixel-wand) (white-color pixel-wand) (invert :boolean)) 731 | :check-error wand) 732 | (defmagickfun "MagickLevelizeImage" :boolean 733 | ((wand magick-wand) (black-point magick-double) 734 | (white-point magick-double) (gamma magick-double)) 735 | :check-error wand) 736 | (defmagickfun "MagickLinearStretchImage" :boolean 737 | ((wand magick-wand) (black-point magick-double) (white-point magick-double)) 738 | :check-error wand) 739 | (defmagickfun "MagickLiquidRescaleImage" :boolean 740 | ((wand magick-wand) (columns :ulong) (rows :ulong) 741 | (delta-x magick-double) (rigidity magick-double)) 742 | :check-error wand) 743 | (defmagickfun "MagickLocalContrastImage" :boolean 744 | ((wand magick-wand) (radius magick-double) (strength magick-double)) 745 | :check-error wand) 746 | ;; deprecated 747 | (defmagickfun "MagickMagnifyImage" :boolean 748 | ((wand magick-wand)) 749 | :check-error wand) 750 | ;; deprecated 751 | (defmagickfun "MagickMapImage" :boolean 752 | ((wand magick-wand) (map-wand magick-wand) (dither :boolean)) 753 | :check-error wand) 754 | ;; deprecated 755 | (defmagickfun "MagickMatteFloodfillImage" :boolean 756 | ((wand magick-wand) (opacity quantum) (fuzz magick-double) 757 | (border-color pixel-wand) (x :long) (y :long)) 758 | :check-error wand) 759 | ;; deprecated 760 | (defmagickfun "MagickMedianFilterImage" :boolean 761 | ((wand magick-wand) (radius magick-double)) 762 | :check-error wand) 763 | (defmagickfun "MagickMeanShiftImage" :boolean 764 | ((wand magick-wand) (width :ulong) (height :ulong) (color-distance magick-double)) 765 | :check-error wand) 766 | (defmagickfun "MagickMinifyImage" :boolean 767 | ((wand magick-wand)) 768 | :check-error wand) 769 | (defmagickfun "MagickModulateImage" :boolean 770 | ((wand magick-wand) (brightness magick-double) (saturation magick-double) (hue magick-double)) 771 | :check-error wand) 772 | (defmagickfun "MagickMotionBlurImage" :boolean 773 | ((wand magick-wand) (radius magick-double) (sigma magick-double) (angle magick-double)) 774 | :check-error wand) 775 | (defmagickfun "MagickNegateImage" :boolean 776 | ((wand magick-wand) (gray :boolean)) 777 | :check-error wand) 778 | (defmagickfun "MagickNegateImageChannel" :boolean 779 | ((wand magick-wand) (channel channel-type) (gray :boolean)) 780 | :check-error wand) 781 | (defmagickfun "MagickNormalizeImage" :boolean 782 | ((wand magick-wand)) 783 | :check-error wand) 784 | (defmagickfun "MagickNormalizeImageChannel" :boolean 785 | ((wand magick-wand) (channel channel-type)) 786 | :check-error wand) 787 | (defmagickfun "MagickOilPaintImage" :boolean 788 | ((wand magick-wand) (radius magick-double)) 789 | :check-error wand) 790 | (defmagickfun "MagickOpaquePaintImage" :boolean 791 | ((wand magick-wand) (target pixel-wand) (fill pixel-wand) (fuzz magick-double) (invert :boolean)) 792 | :check-error wand) 793 | (defmagickfun "MagickOptimizeImageTransparency" :boolean 794 | ((wand magick-wand)) 795 | :check-error wand) 796 | (defmagickfun "MagickOrderedDitherImage" :boolean 797 | ((wand magick-wand) (threshold-map magick-string)) 798 | :check-error wand) 799 | ;; deprecated 800 | (defmagickfun "MagickPaintOpaqueImage" :boolean 801 | ((wand magick-wand) (target pixel-wand) (fill pixel-wand) (fuzz magick-double)) 802 | :check-error wand) 803 | ;; deprecated 804 | (defmagickfun "MagickPaintOpaqueImageChannel" :boolean 805 | ((wand magick-wand) (channel channel-type) 806 | (target pixel-wand) (fill pixel-wand) (fuzz magick-double)) 807 | :check-error wand) 808 | ;; deprecated 809 | (defmagickfun "MagickPaintTransparentImage" :boolean 810 | ((wand magick-wand) (target pixel-wand) (opacity quantum) (fuzz magick-double)) 811 | :check-error wand) 812 | (defmagickfun "MagickPolaroidImage" :boolean 813 | ((wand magick-wand) (drawing-wand drawing-wand) (caption magick-string) 814 | (angle magick-double) (method pixel-interpolate-method)) 815 | :check-error wand) 816 | (defmagickfun "MagickPolynomialImage" :boolean 817 | ((wand magick-wand) (num (:dynarray-length :ulong terms)) (terms (:dynarray magick-double))) 818 | :check-error wand) 819 | (defmagickfun "MagickPosterizeImage" :boolean 820 | ((wand magick-wand) (levels :ulong) (dither :boolean)) 821 | :check-error wand) 822 | (defmagickfun "MagickProfileImage" :boolean 823 | ((wand magick-wand) (name magick-string) 824 | (profile (:dynarray :uint8)) 825 | (length (:dynarray-length size-t profile))) 826 | :check-error wand) 827 | (defmagickfun "MagickQuantizeImage" :boolean 828 | ((wand magick-wand) (num-colors :ulong) (colorspace colorspace-type) 829 | (tree-depth :ulong) (dither :boolean) (measure-error :boolean)) 830 | :check-error wand) 831 | (defmagickfun "MagickQuantizeImages" :boolean 832 | ((wand magick-wand) (num-colors :ulong) (colorspace colorspace-type) 833 | (tree-depth :ulong) (dither :boolean) (measure-error :boolean)) 834 | :check-error wand) 835 | ;; deprecated 836 | (defmagickfun "MagickRadialBlurImage" :boolean 837 | ((wand magick-wand) (angle magick-double)) 838 | :check-error wand) 839 | ;; deprecated 840 | (defmagickfun "MagickRadialBlurImageChannel" :boolean 841 | ((wand magick-wand) (channel channel-type) (angle magick-double)) 842 | :check-error wand) 843 | (defmagickfun "MagickRaiseImage" :boolean 844 | ((wand magick-wand) (width :ulong) (height :ulong) 845 | (x :long) (y :long) (raise :boolean)) 846 | :check-error wand) 847 | (defmagickfun "MagickRandomThresholdImage" :boolean 848 | ((wand magick-wand) (low magick-double) (high magick-double)) 849 | :check-error wand) 850 | (defmagickfun "MagickRangeThresholdImage" :boolean 851 | ((wand magick-wand) (low-black magick-double) (low-white magick-double) 852 | (high-black magick-double) (high-white magick-double)) 853 | :check-error wand) 854 | ;; deprecated 855 | (defmagickfun "MagickReduceNoiseImage" :boolean 856 | ((wand magick-wand) (radius magick-double)) 857 | :check-error wand) 858 | (defmagickfun "MagickRemapImage" :boolean 859 | ((wand magick-wand) (remap-wand magick-wand) (method dither-method)) 860 | :check-error wand) 861 | (defmagickfun "MagickResampleImage" :boolean 862 | ((wand magick-wand) (x-resolution magick-double) (y-resolution magick-double) 863 | (filter filter-type)) 864 | :check-error wand) 865 | (defmagickfun "MagickResetImagePage" :boolean 866 | ((wand magick-wand) (page magick-string)) 867 | :check-error wand) 868 | (defmagickfun "MagickResizeImage" :boolean 869 | ((wand magick-wand) (columns :ulong) (rows :ulong) (filter filter-type)) 870 | :check-error wand) 871 | (defmagickfun "MagickRollImage" :boolean 872 | ((wand magick-wand) (x :long) (y :long)) 873 | :check-error wand) 874 | (defmagickfun "MagickRotateImage" :boolean 875 | ((wand magick-wand) (background pixel-wand) (degrees magick-double)) 876 | :check-error wand) 877 | (defmagickfun "MagickRotationalBlurImage" :boolean 878 | ((wand magick-wand) (angle magick-double)) 879 | :check-error wand) 880 | (defmagickfun "MagickSampleImage" :boolean 881 | ((wand magick-wand) (columns :ulong) (rows :ulong)) 882 | :check-error wand) 883 | (defmagickfun "MagickScaleImage" :boolean 884 | ((wand magick-wand) (columns :ulong) (rows :ulong)) 885 | :check-error wand) 886 | (defmagickfun "MagickSegmentImage" :boolean 887 | ((wand magick-wand) (colorspace colorspace-type) (verbose :boolean) 888 | (cluster-threshold magick-double) (smooth-threshold magick-double)) 889 | :check-error wand) 890 | (defmagickfun "MagickSelectiveBlurImage" :boolean 891 | ((wand magick-wand) (radius magick-double) (sigma magick-double) (threshold magick-double)) 892 | :check-error wand) 893 | (defmagickfun "MagickSeparateImage" :boolean 894 | ((wand magick-wand) (channel channel-type)) 895 | :check-error wand) 896 | ;; deprecated 897 | (defmagickfun "MagickSeparateImageChannel" :boolean 898 | ((wand magick-wand) (channel channel-type)) 899 | :check-error wand) 900 | (defmagickfun "MagickSepiaToneImage" :boolean 901 | ((wand magick-wand) (threshold magick-double)) 902 | :check-error wand) 903 | (defmagickfun "MagickShadeImage" :boolean 904 | ((wand magick-wand) (gray :boolean) (asimuth magick-double) (elevation magick-double)) 905 | :check-error wand) 906 | (defmagickfun "MagickShadowImage" :boolean 907 | ((wand magick-wand) (alpha magick-double) (sigma magick-double) (x :long) (y :long)) 908 | :check-error wand) 909 | (defmagickfun "MagickSharpenImage" :boolean 910 | ((wand magick-wand) (radius magick-double) (sigma magick-double)) 911 | :check-error wand) 912 | (defmagickfun "MagickShaveImage" :boolean 913 | ((wand magick-wand) (columns :ulong) (rows :ulong)) 914 | :check-error wand) 915 | (defmagickfun "MagickShearImage" :boolean 916 | ((wand magick-wand) (background pixel-wand) (x-shear magick-double) (y-shear magick-double)) 917 | :check-error wand) 918 | (defmagickfun "MagickSigmoidalContrastImage" :boolean 919 | ((wand magick-wand) (sharpen :boolean) (alpha magick-double) (beta magick-double)) 920 | :check-error wand) 921 | (defmagickfun "MagickSketchImage" :boolean 922 | ((wand magick-wand) (radius magick-double) (sigma magick-double) (angle magick-double)) 923 | :check-error wand) 924 | (defmagickfun "MagickSolarizeImage" :boolean 925 | ((wand magick-wand) (threshold magick-double)) 926 | :check-error wand) 927 | (defmagickfun "MagickSparseColorImage" :boolean 928 | ((wand magick-wand) (method sparse-color-method) 929 | (num (:dynarray-length :ulong args)) (args (:dynarray magick-double))) 930 | :check-error wand) 931 | (defmagickfun "MagickSpliceImage" :boolean 932 | ((wand magick-wand) (width :ulong) (height :ulong) (x :long) (y :long)) 933 | :check-error wand) 934 | (defmagickfun "MagickSpreadImage" :boolean 935 | ((wand magick-wand) (method pixel-interpolate-method) (radius magick-double)) 936 | :check-error wand) 937 | (defmagickfun "MagickStatisticImage" :boolean 938 | ((wand magick-wand) (type statistic-type) (width :ulong) (height :ulong)) 939 | :check-error wand) 940 | (defmagickfun "MagickStripImage" :boolean 941 | ((wand magick-wand)) 942 | :check-error wand) 943 | (defmagickfun "MagickSwirlImage" :boolean 944 | ((wand magick-wand) (degrees magick-double) (method pixel-interpolate-method)) 945 | :check-error wand) 946 | (defmagickfun "MagickThresholdImage" :boolean 947 | ((wand magick-wand) (threshold magick-double)) 948 | :check-error wand) 949 | (defmagickfun "MagickThresholdImageChannel" :boolean 950 | ((wand magick-wand) (channel channel-type) (threshold magick-double)) 951 | :check-error wand) 952 | (defmagickfun "MagickThumbnailImage" :boolean 953 | ((wand magick-wand) (columns :ulong) (rows :ulong)) 954 | :check-error wand) 955 | (defmagickfun "MagickTintImage" :boolean 956 | ((wand magick-wand) (tint pixel-wand) (blend pixel-wand)) 957 | :check-error wand) 958 | (defmagickfun "MagickTransformImageColorspace" :boolean 959 | ((wand magick-wand) (colorspace colorspace-type)) 960 | :check-error wand) 961 | (defmagickfun "MagickTransparentPaintImage" :boolean 962 | ((wand magick-wand) (target pixel-wand) (alpha magick-double) 963 | (fuzz magick-double) (invert :boolean)) 964 | :check-error wand) 965 | (defmagickfun "MagickTransposeImage" :boolean 966 | ((wand magick-wand)) 967 | :check-error wand) 968 | (defmagickfun "MagickTransverseImage" :boolean 969 | ((wand magick-wand)) 970 | :check-error wand) 971 | (defmagickfun "MagickTrimImage" :boolean 972 | ((wand magick-wand) (fuzz magick-double)) 973 | :check-error wand) 974 | (defmagickfun "MagickUniqueImageColors" :boolean 975 | ((wand magick-wand)) 976 | :check-error wand) 977 | (defmagickfun "MagickUnsharpMaskImage" :boolean 978 | ((wand magick-wand) (radius magick-double) (sigma magick-double) 979 | (gain magick-double) (threshold magick-double)) 980 | :check-error wand) 981 | (defmagickfun "MagickVignetteImage" :boolean 982 | ((wand magick-wand) (radius magick-double) (sigma magick-double) (x :long) (y :long)) 983 | :check-error wand) 984 | (defmagickfun "MagickWaveImage" :boolean 985 | ((wand magick-wand) (amplitude magick-double) 986 | (wave-length magick-double) (method pixel-interpolate-method)) 987 | :check-error wand) 988 | (defmagickfun "MagickWaveletDenoiseImage" :boolean 989 | ((wand magick-wand) (threshold magick-double) (softness magick-double)) 990 | :check-error wand) 991 | (defmagickfun "MagickWhiteBalanceImage" :boolean 992 | ((wand magick-wand)) 993 | :check-error wand) 994 | (defmagickfun "MagickWhiteThresholdImage" :boolean 995 | ((wand magick-wand) (threshold pixel-wand)) 996 | :check-error wand) 997 | 998 | 999 | 1000 | 1001 | ;;; Pixel Wands 1002 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1003 | 1004 | ;; Creation, destruction, etc. 1005 | 1006 | (defmagickfun "NewPixelWand" pixel-wand ()) 1007 | (defmagickfun "DestroyPixelWand" pixel-wand ((wand pixel-wand))) 1008 | (defmagickfun "IsPixelWand" :boolean ((wand pixel-wand))) 1009 | (defmagickfun "ClearPixelWand" :void ((wand pixel-wand))) 1010 | (defmagickfun "IsPixelWandSimilar" :boolean ((wand1 pixel-wand) (wand2 pixel-wand) (fuzz magick-double))) 1011 | 1012 | 1013 | ;; Get / set color as string 1014 | 1015 | (defmagickfun "PixelGetColorAsString" magick-string/free ((wand pixel-wand))) 1016 | (defmagickfun "PixelGetColorAsNormalizedString" magick-string/free ((wand pixel-wand))) 1017 | (defmagickfun "PixelSetColor" :boolean ((wand pixel-wand) (color magick-string)) :check-error wand) 1018 | 1019 | 1020 | ;; Components as double 1021 | 1022 | (defmagickfun "PixelGetAlpha" :double ((wand pixel-wand))) 1023 | (defmagickfun "PixelGetBlack" :double ((wand pixel-wand))) 1024 | (defmagickfun "PixelGetBlue" :double ((wand pixel-wand))) 1025 | (defmagickfun "PixelGetCyan" :double ((wand pixel-wand))) 1026 | (defmagickfun "PixelGetGreen" :double ((wand pixel-wand))) 1027 | (defmagickfun "PixelGetMagenta" :double ((wand pixel-wand))) 1028 | (defmagickfun "PixelGetOpacity" :double ((wand pixel-wand))) 1029 | (defmagickfun "PixelGetRed" :double ((wand pixel-wand))) 1030 | (defmagickfun "PixelGetYellow" :double ((wand pixel-wand))) 1031 | 1032 | (defmagickfun "PixelSetAlpha" :void ((wand pixel-wand) (alpha magick-double))) 1033 | (defmagickfun "PixelSetBlack" :void ((wand pixel-wand) (black magick-double))) 1034 | (defmagickfun "PixelSetBlue" :void ((wand pixel-wand) (blue magick-double))) 1035 | (defmagickfun "PixelSetCyan" :void ((wand pixel-wand) (cyan magick-double))) 1036 | (defmagickfun "PixelSetGreen" :void ((wand pixel-wand) (green magick-double))) 1037 | (defmagickfun "PixelSetMagenta" :void ((wand pixel-wand) (magenta magick-double))) 1038 | (defmagickfun "PixelSetOpacity" :void ((wand pixel-wand) (opacity magick-double))) 1039 | (defmagickfun "PixelSetRed" :void ((wand pixel-wand) (red magick-double))) 1040 | (defmagickfun "PixelSetYellow" :void ((wand pixel-wand) (yellow magick-double))) 1041 | 1042 | 1043 | ;; Components as quantum 1044 | 1045 | (defmagickfun "PixelGetAlphaQuantum" quantum ((wand pixel-wand))) 1046 | (defmagickfun "PixelGetBlackQuantum" quantum ((wand pixel-wand))) 1047 | (defmagickfun "PixelGetBlueQuantum" quantum ((wand pixel-wand))) 1048 | (defmagickfun "PixelGetCyanQuantum" quantum ((wand pixel-wand))) 1049 | (defmagickfun "PixelGetGreenQuantum" quantum ((wand pixel-wand))) 1050 | (defmagickfun "PixelGetMagentaQuantum" quantum ((wand pixel-wand))) 1051 | (defmagickfun "PixelGetOpacityQuantum" quantum ((wand pixel-wand))) 1052 | (defmagickfun "PixelGetRedQuantum" quantum ((wand pixel-wand))) 1053 | (defmagickfun "PixelGetYellowQuantum" quantum ((wand pixel-wand))) 1054 | 1055 | (defmagickfun "PixelSetAlphaQuantum" :void ((wand pixel-wand) (alpha quantum))) 1056 | (defmagickfun "PixelSetBlackQuantum" :void ((wand pixel-wand) (black quantum))) 1057 | (defmagickfun "PixelSetBlueQuantum" :void ((wand pixel-wand) (blue quantum))) 1058 | (defmagickfun "PixelSetCyanQuantum" :void ((wand pixel-wand) (cyan quantum))) 1059 | (defmagickfun "PixelSetGreenQuantum" :void ((wand pixel-wand) (green quantum))) 1060 | (defmagickfun "PixelSetMagentaQuantum" :void ((wand pixel-wand) (magenta quantum))) 1061 | (defmagickfun "PixelSetOpacityQuantum" :void ((wand pixel-wand) (opacity quantum))) 1062 | (defmagickfun "PixelSetRedQuantum" :void ((wand pixel-wand) (red quantum))) 1063 | (defmagickfun "PixelSetYellowQuantum" :void ((wand pixel-wand) (yellow quantum))) 1064 | 1065 | 1066 | ;; Other accessors 1067 | 1068 | (defmagickfun "PixelGetColorCount" :ulong ((wand pixel-wand))) 1069 | (defmagickfun "PixelSetColorCount" :void ((wand pixel-wand) (count :ulong))) 1070 | (defmagickfun "PixelGetFuzz" :double ((wand pixel-wand))) 1071 | (defmagickfun "PixelSetFuzz" :void ((wand pixel-wand) (fuzz magick-double))) 1072 | (defmagickfun "PixelGetIndex" quantum ((wand pixel-wand))) 1073 | (defmagickfun "PixelSetIndex" :void ((wand pixel-wand) (index quantum))) 1074 | 1075 | 1076 | ;;; Drawing Wands 1077 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1078 | 1079 | ;; Creation, destruction, etc. 1080 | 1081 | (defmagickfun "NewDrawingWand" drawing-wand ()) 1082 | (defmagickfun "DestroyDrawingWand" drawing-wand ((wand drawing-wand))) 1083 | (defmagickfun "IsDrawingWand" :boolean ((wand drawing-wand))) 1084 | (defmagickfun "CloneDrawingWand" drawing-wand ((wand drawing-wand))) 1085 | (defmagickfun "ClearDrawingWand" :void ((wand drawing-wand))) 1086 | 1087 | 1088 | ;; Attributes 1089 | 1090 | (defmagickfun "DrawGetTextAlignment" align-type ((wand drawing-wand))) 1091 | (defmagickfun "DrawGetClipPath" magick-string/free ((wand drawing-wand))) 1092 | (defmagickfun "DrawGetFont" magick-string/free ((wand drawing-wand))) 1093 | (defmagickfun "DrawGetFontFamily" magick-string/free ((wand drawing-wand))) 1094 | (defmagickfun "DrawGetTextEncoding" magick-string/free ((wand drawing-wand))) 1095 | (defmagickfun "DrawGetVectorGraphics" magick-string/free ((wand drawing-wand))) 1096 | (defmagickfun "DrawGetClipUnits" clip-path-units ((wand drawing-wand))) 1097 | (defmagickfun "DrawGetTextDecoration" decoration-type ((wand drawing-wand))) 1098 | (defmagickfun "DrawGetFillAlpha" :double ((wand drawing-wand))) ;deprecated 1099 | (defmagickfun "DrawGetFontSize" :double ((wand drawing-wand))) 1100 | (defmagickfun "DrawGetStrokeDashOffset" :double ((wand drawing-wand))) 1101 | (defmagickfun "DrawGetStrokeAlpha" :double ((wand drawing-wand))) ;deprecated 1102 | (defmagickfun "DrawGetStrokeWidth" :double ((wand drawing-wand))) 1103 | (defmagickfun "DrawGetClipRule" fill-rule ((wand drawing-wand))) 1104 | (defmagickfun "DrawGetFillRule" fill-rule ((wand drawing-wand))) 1105 | (defmagickfun "DrawGetGravity" gravity-type ((wand drawing-wand))) 1106 | (defmagickfun "DrawGetStrokeLineCap" line-cap ((wand drawing-wand))) 1107 | (defmagickfun "DrawGetStrokeLineJoin" line-join ((wand drawing-wand))) 1108 | (defmagickfun "DrawGetStrokeAntialias" :boolean ((wand drawing-wand))) 1109 | (defmagickfun "DrawGetTextAntialias" :boolean ((wand drawing-wand))) 1110 | (defmagickfun "DrawGetFontStretch" stretch-type ((wand drawing-wand))) 1111 | (defmagickfun "DrawGetFontStyle" style-type ((wand drawing-wand))) 1112 | (defmagickfun "DrawGetFontWeight" :ulong ((wand drawing-wand))) 1113 | (defmagickfun "DrawGetStrokeMiterLimit" :ulong ((wand drawing-wand))) 1114 | 1115 | (defmagickfun "DrawSetClipRule" :void ((wand drawing-wand) (rule fill-rule))) 1116 | (defmagickfun "DrawSetClipUnits" :void ((wand drawing-wand) (units clip-path-units))) 1117 | (defmagickfun "DrawSetFillAlpha" :void ((wand drawing-wand) (alpha magick-double))) ;deprecated 1118 | (defmagickfun "DrawSetFillRule" :void ((wand drawing-wand) (rule fill-rule))) 1119 | (defmagickfun "DrawSetFontSize" :void ((wand drawing-wand) (size magick-double))) 1120 | (defmagickfun "DrawSetFontStretch" :void ((wand drawing-wand) (stretch stretch-type))) 1121 | (defmagickfun "DrawSetFontStyle" :void ((wand drawing-wand) (style style-type))) 1122 | (defmagickfun "DrawSetFontWeight" :void ((wand drawing-wand) (weight :ulong))) 1123 | (defmagickfun "DrawSetGravity" :void ((wand drawing-wand) (gravity gravity-type))) 1124 | (defmagickfun "DrawSetStrokeAntialias" :void ((wand drawing-wand) (antialias :boolean))) 1125 | (defmagickfun "DrawSetStrokeDashOffset" :void ((wand drawing-wand) (offset magick-double))) 1126 | (defmagickfun "DrawSetStrokeLineCap" :void ((wand drawing-wand) (cap line-cap))) 1127 | (defmagickfun "DrawSetStrokeLineJoin" :void ((wand drawing-wand) (join line-join))) 1128 | (defmagickfun "DrawSetStrokeMiterLimit" :void ((wand drawing-wand) (limit :ulong))) 1129 | (defmagickfun "DrawSetStrokeAlpha" :void ((wand drawing-wand) (alpha magick-double))) ;deprecated 1130 | (defmagickfun "DrawSetStrokeWidth" :void ((wand drawing-wand) (width magick-double))) 1131 | (defmagickfun "DrawSetTextAlignment" :void ((wand drawing-wand) (align align-type))) 1132 | (defmagickfun "DrawSetTextAntialias" :void ((wand drawing-wand) (antialias :boolean))) 1133 | (defmagickfun "DrawSetTextDecoration" :void ((wand drawing-wand) (deco decoration-type))) 1134 | (defmagickfun "DrawSetTextEncoding" :void ((wand drawing-wand) (encoding magick-string))) 1135 | (defmagickfun "DrawSetViewbox" :void ((wand drawing-wand) (x1 :ulong) (y1 :ulong) (x2 :ulong) (y2 :ulong))) 1136 | 1137 | (defmagickfun "DrawGetFillColor" :void ((dwand drawing-wand) (pwand pixel-wand))) 1138 | (defmagickfun "DrawGetStrokeColor" :void ((dwand drawing-wand) (pwand pixel-wand))) 1139 | (defmagickfun "DrawGetTextUnderColor" :void ((dwand drawing-wand) (pwand pixel-wand))) 1140 | 1141 | (defmagickfun "DrawSetFillColor" :void ((dwand drawing-wand) (pwand pixel-wand))) 1142 | (defmagickfun "DrawSetStrokeColor" :void ((dwand drawing-wand) (pwand pixel-wand))) 1143 | (defmagickfun "DrawSetTextUnderColor" :void ((dwand drawing-wand) (pwand pixel-wand))) 1144 | 1145 | (defmagickfun "DrawSetFont" :boolean ((dwand drawing-wand) (font-name magick-string))) 1146 | (defmagickfun "DrawSetFontFamily" :boolean ((dwand drawing-wand) (font-family magick-string))) 1147 | 1148 | ;; Draw operations 1149 | 1150 | (defmagickfun "DrawAnnotation" :void ((dwand drawing-wand) (x magick-double) (y magick-double) 1151 | (text magick-string))) 1152 | (defmagickfun "DrawArc" :void ((dwand drawing-wand) (sx magick-double) (sy magick-double) 1153 | (ex magick-double) (ey magick-double) 1154 | (sd magick-double) (ed magick-double))) 1155 | (defmagickfun "DrawCircle" :void ((dwand drawing-wand) (ox magick-double) (oy magick-double) 1156 | (px magick-double) (py magick-double))) 1157 | (defmagickfun "DrawColor" :void ((dwand drawing-wand) (x magick-double) (y magick-double) 1158 | (method paint-method))) 1159 | (defmagickfun "DrawComment" :void ((dwand drawing-wand) (comment magick-string))) 1160 | (defmagickfun "DrawEllipse" :void ((dwand drawing-wand) (ox magick-double) (oy magick-double) 1161 | (rx magick-double) (ry magick-double) 1162 | (start magick-double) (end magick-double))) 1163 | (defmagickfun "DrawLine" :void ((dwand drawing-wand) (sx magick-double) (sy magick-double) 1164 | (ex magick-double) (ey magick-double))) 1165 | (defmagickfun "DrawMatte" :void ((dwand drawing-wand) (x magick-double) (y magick-double) 1166 | (method paint-method))) 1167 | (defmagickfun "DrawPoint" :void ((dwand drawing-wand) (x magick-double) (y magick-double))) 1168 | (defmagickfun "DrawRectangle" :void ((dwand drawing-wand) (x1 magick-double) (y1 magick-double) 1169 | (x2 magick-double) (y2 magick-double))) 1170 | (defmagickfun "DrawRoundRectangle" :void ((dwand drawing-wand) (x1 magick-double) (y1 magick-double) 1171 | (x2 magick-double) (y2 magick-double) 1172 | (rx magick-double) (ry magick-double))) 1173 | 1174 | 1175 | ;; Path operations 1176 | 1177 | (defmagickfun "DrawPathClose" :void ((dwand drawing-wand))) 1178 | (defmagickfun "DrawPathCurveToAbsolute" :void 1179 | ((dwand drawing-wand) 1180 | (x1 magick-double) (y1 magick-double) (x2 magick-double) (y2 magick-double) 1181 | (x magick-double) (y magick-double))) 1182 | (defmagickfun "DrawPathCurveToRelative" :void 1183 | ((dwand drawing-wand) 1184 | (x1 magick-double) (y1 magick-double) (x2 magick-double) (y2 magick-double) 1185 | (x magick-double) (y magick-double))) 1186 | (defmagickfun "DrawPathCurveToQuadraticBezierAbsolute" :void 1187 | ((dwand drawing-wand) (x1 magick-double) (y1 magick-double) (x magick-double) (y magick-double))) 1188 | (defmagickfun "DrawPathCurveToQuadraticBezierRelative" :void 1189 | ((dwand drawing-wand) (x1 magick-double) (y1 magick-double) (x magick-double) (y magick-double))) 1190 | (defmagickfun "DrawPathCurveToQuadraticBezierSmoothAbsolute" :void 1191 | ((dwand drawing-wand) (x magick-double) (y magick-double))) 1192 | (defmagickfun "DrawPathCurveToQuadraticBezierSmoothRelative" :void 1193 | ((dwand drawing-wand) (x magick-double) (y magick-double))) 1194 | (defmagickfun "DrawPathCurveToSmoothAbsolute" :void 1195 | ((dwand drawing-wand) (x2 magick-double) (y2 magick-double) (x magick-double) (y magick-double))) 1196 | (defmagickfun "DrawPathCurveToSmoothRelative" :void 1197 | ((dwand drawing-wand) (x2 magick-double) (y2 magick-double) (x magick-double) (y magick-double))) 1198 | (defmagickfun "DrawPathEllipticArcAbsolute" :void 1199 | ((dwand drawing-wand) 1200 | (rx magick-double) (ry magick-double) (x-axis-rotation magick-double) 1201 | (large-arc-p :boolean) (sweep-p :boolean) (x magick-double) (y magick-double))) 1202 | (defmagickfun "DrawPathEllipticArcRelative" :void 1203 | ((dwand drawing-wand) 1204 | (rx magick-double) (ry magick-double) (x-axis-rotation magick-double) 1205 | (large-arc-p :boolean) (sweep-p :boolean) (x magick-double) (y magick-double))) 1206 | (defmagickfun "DrawPathFinish" :void ((dwand drawing-wand))) 1207 | (defmagickfun "DrawPathLineToAbsolute" :void 1208 | ((dwand drawing-wand) (x magick-double) (y magick-double))) 1209 | (defmagickfun "DrawPathLineToRelative" :void 1210 | ((dwand drawing-wand) (x magick-double) (y magick-double))) 1211 | (defmagickfun "DrawPathLineToHorizontalAbsolute" :void 1212 | ((dwand drawing-wand) (x magick-double))) 1213 | (defmagickfun "DrawPathLineToHorizontalRelative" :void 1214 | ((dwand drawing-wand) (x magick-double))) 1215 | (defmagickfun "DrawPathLineToVerticalAbsolute" :void 1216 | ((dwand drawing-wand) (y magick-double))) 1217 | (defmagickfun "DrawPathLineToVerticalRelative" :void 1218 | ((dwand drawing-wand) (y magick-double))) 1219 | (defmagickfun "DrawPathMoveToAbsolute" :void 1220 | ((dwand drawing-wand) (x magick-double) (y magick-double))) 1221 | (defmagickfun "DrawPathMoveToRelative" :void 1222 | ((dwand drawing-wand) (x magick-double) (y magick-double))) 1223 | (defmagickfun "DrawPathStart" :void ((dwand drawing-wand))) 1224 | --------------------------------------------------------------------------------