Imago is an image manipulation library for Common Lisp. It supports images in
png, pcx, portable bitmap (.pnm), Truevision TGA (.tga) and jpeg formats. You
can read an image with imago:read-image and write an image with
imago:write-format where format is one of png, pcx, pnm, tga or
jpg.
Reading from and writing to jpeg files with libjpeg-turbo
You can use more advanced libjpeg-turbo library to
deal with jpeg files by loading imago/jpeg-turbo system. Make sure that
libjpeg-turbo is installed on your system. Use
imago-jpeg-turbo:read-jpg-turbo and imago-jpeg-turbo:write-jpg-turbo
functions (or just imago:read-image and imago:write-image) to use this
functionality.
Alternative png I/O with imago/pngio
You can use more advanced and faster
pngload library to read png files by
loading imago/pngio system. Use imago-pngio:read-png (or just
imago:read-image) to use this functionality. NB:pngload automatically
converts indexed color images to RGB (or ARGB) images. If you want to work with
indexed images, use old png loader instead. Also
zpng (via imago-pngio:write-png) library will
be used for saving png images.
Creating an image
To create an image look at the documentation for image classes (like
imago:rgb-image or imago:grayscale-image). You need to make an instance of
one of those classes by passing :w, :h and optionally :initial-color
keyword arguments to make-instance. Alternatively, you can use
make-XXX-image and make-XXX-image-from-pixels functions:
;; Create 100x100 px black grayscale image
(imago:make-grayscale-image 100 100)
;; Create 400x100 px red RGB image
(imago:make-rgb-image 400 100 (imago:make-color 255 0 0))
;; Create 400x100 px half-transparent red RGB image
(imago:make-rgb-image 400 100 (imago:make-color 255 0 0 127))
;; Create an image from an array of pixels
(imago:make-rgb-image-from-pixels
(make-array '(100 100)
:element-type 'imago:rgb-pixel
:initial-element (imago:make-color 0 255 255)))