trivial thumbnail
1.1.0Tiny library to create image thumbnails with imagemagick.
Table of Contents
About Trivial-Thumbnail
A tiny library to create thumbnails with ImageMagick. The binaries convert
and mogrify
need to be available on your system for this to work.
How To
The main function to use is create
.
(thumbnail:create #p"~/input.png" #p"~/input-thumb.png")
=> #p"~/input-thumb.png"
Of course it allows for different kinds of thumbnail generation with the crop
argument:
(thumbnail:create #p"~/input.png" #p"~/input-thumb.png" :crop :WIDTH)
(thumbnail:create #p"~/input.png" #p"~/input-thumb.png" :crop :HEIGHT)
(thumbnail:create #p"~/input.png" #p"~/input-thumb.png" :crop T)
Using :WIDTH
means that the image is first scaled down preserving the aspect ratio to fit into the given height and then crops the remaining width to fit the given width. :HEIGHT
works similarly. T
just crops the image without any scaling.
This library uses ImageMagick mostly because it can handle gif animations properly, which a lot of other tools cannot. Processing animation is calculation-intensive though, so if you want to disable that (resulting in a static gif), you can pass :preserve-gif NIL
.
Trivial-Thumbnail attempts to locate the necessary binaries automatically, searching the usual paths such as /usr/bin
, /usr/local/bin
and C:/windows/system32/
, C:/Program Files/ImageMagick*/
. If it fails to find a suitable binary, it throws a warning at startup. When the binary is somewhere else, but still within your PATH
, it should still work properly. Otherwise you will have to set *CONVERT-BIN*
and *MOGRIFY-BIN*
yourself.
System Information
Definition Index
-
TRIVIAL-THUMBNAIL
- THUMBNAIL
- ORG.TYMOONNEXT.TRIVIAL-THUMBNAIL
No documentation provided.-
EXTERNAL SPECIAL-VARIABLE *CONVERT-BIN*
String or pathname designating the location of the imagemagick CONVERT binary.
-
EXTERNAL SPECIAL-VARIABLE *MOGRIFY-BIN*
String or pathname designating the location of the imagemagick MOGRIFY binary.
-
EXTERNAL FUNCTION CONVERT
- IN
- OUT
- &REST
- ARGS
- &REST
Runs imagemagick's CONVERT on IN with the result to OUT using the command-line ARGS.
-
EXTERNAL FUNCTION CREATE
- IN
- OUT
- &KEY
- WIDTH
- HEIGHT
- CROP
- QUALITY
- PRESERVE-GIF
- IF-EXISTS
- &REST
Creates a thumbnail of IN with the result to OUT. IN --- A pathname or string to the source image. Strings are parsed using UIOP:PARSE-NATIVE-NAMESTRING. OUT --- A pathname or string to the source image or NIL. If NIL, OUT is the same as IN, with 'thumb-' prefixed to the pathname-name. WIDTH --- The width of the thumbnail in pixels. HEIGHT --- The height of the thumbnail in pixels. CROP --- How to create the thumbnail. Can be one of the following: NIL Same as :CONTAIN :CONTAIN Scale the image to fit the larger dimension. :COVER Scale the image to fit the lower dimension, then crop. :WIDTH Scale the image to HEIGHT and crop the width down to fit WIDTH. :HEIGHT Scale the image to WIDTH and crop the height down to fit HEIGHT. T Crop the image width and height to fit WIDTH and HEIGHT. QUALITY --- Percentage for the quality to use (0-100). PRESERVE-GIF --- Whether to run imagemagick with -coalesce, which preserves GIF animations, but will take more time to compute. IF-EXISTS --- What to do if OUT exists. Can be one of the following: NIL Don't create a thumbnail and just return NIL. :ERROR Signal an error. :WARN Signal a warning. :SUPERSEDE Overwrite the file. Returns OUT.
-
EXTERNAL FUNCTION MOGRIFY
- IN
- &REST
- ARGS
- &REST
Runs imagemagick's MOGRIFY on IN using the command-line ARGS.