UNfunny/unfunny/wand.scm

82 lines
2.6 KiB
Scheme

;; Copyright (C) 2024 Skylar Widulski <cobra@vern.cc>
;;
;; This file is part of UNfunny
;;
;; UNfunny is free software: you can redistribute it and/or modify it under the
;; terms of the GNU Affero General Public License as published by the Free
;; Software Foundation, either version 3 of the License, or (at your option) any
;; later version.
;;
;; This program is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
;; for more details.
;;
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(define-module (unfunny wand)
#:use-module (rnrs)
#:use-module (system foreign)
#:use-module (system foreign-library)
#:export (magick-wand-genesis
new-magick-wand
magick-read-image-blob
magick-crop-image
magick-get-image-width
magick-get-image-height
magick-write-image
destroy-magick-wand
magick-wand-terminus))
(define wand
(dynamic-link
(if (getenv "WAND_PATH")
(getenv "WAND_PATH")
"libMagickWand-6.Q16")))
(define magick-wand-genesis
(pointer->procedure void
(dynamic-func "MagickWandGenesis" wand)
(list)))
(define new-magick-wand
(pointer->procedure '*
(dynamic-func "NewMagickWand" wand)
(list)))
(define magick-read-image-blob
(pointer->procedure '*
(dynamic-func "MagickReadImageBlob" wand)
(list '* '* size_t)))
(define magick-crop-image
(pointer->procedure int
(dynamic-func "MagickCropImage" wand)
(list '* size_t size_t ssize_t ssize_t)))
(define magick-get-image-width
(pointer->procedure size_t
(dynamic-func "MagickGetImageWidth" wand)
(list '*)))
(define magick-get-image-height
(pointer->procedure size_t
(dynamic-func "MagickGetImageHeight" wand)
(list '*)))
(define magick-write-image
(pointer->procedure '*
(dynamic-func "MagickWriteImage" wand)
(list '* '*)))
(define destroy-magick-wand
(pointer->procedure '*
(dynamic-func "DestroyMagickWand" wand)
(list '*)))
(define magick-wand-terminus
(pointer->procedure void
(dynamic-func "MagickWandTerminus" wand)
(list)))