The trivial-thumbnail Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The trivial-thumbnail Reference Manual

This is the trivial-thumbnail Reference Manual, version 1.1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 06:04:35 2022 GMT+0.

Table of Contents


1 Introduction

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.


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 trivial-thumbnail

Tiny library to create image thumbnails with imagemagick.

Maintainer

Nicolas Hafner <shinmera@tymoon.eu>

Author

Nicolas Hafner <shinmera@tymoon.eu>

Home Page

https://Shinmera.github.io/trivial-thumbnail/

Source Control

(GIT https://github.com/Shinmera/trivial-thumbnail.git)

Bug Tracker

https://github.com/Shinmera/trivial-thumbnail/issues

License

zlib

Version

1.1.0

Dependency

uiop (system).

Source

trivial-thumbnail.asd.

Child Component

thumbnail.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


3.1.1 trivial-thumbnail/trivial-thumbnail.asd

Source

trivial-thumbnail.asd.

Parent Component

trivial-thumbnail (system).

ASDF Systems

trivial-thumbnail.


3.1.2 trivial-thumbnail/thumbnail.lisp

Source

trivial-thumbnail.asd.

Parent Component

trivial-thumbnail (system).

Packages

trivial-thumbnail.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 trivial-thumbnail

Source

thumbnail.lisp.

Nicknames
  • org.tymoonnext.trivial-thumbnail
  • thumbnail
Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Special variables

Special Variable: *convert-bin*

String or pathname designating the location of the imagemagick CONVERT binary.

Package

trivial-thumbnail.

Source

thumbnail.lisp.

Special Variable: *mogrify-bin*

String or pathname designating the location of the imagemagick MOGRIFY binary.

Package

trivial-thumbnail.

Source

thumbnail.lisp.


5.1.2 Ordinary functions

Function: convert (in out &rest args)

Runs imagemagick’s CONVERT on IN with the result to OUT using the command-line ARGS.

Package

trivial-thumbnail.

Source

thumbnail.lisp.

Function: create (in out &key width height crop quality preserve-gif if-exists)

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.

Package

trivial-thumbnail.

Source

thumbnail.lisp.

Function: mogrify (in &rest args)

Runs imagemagick’s MOGRIFY on IN using the command-line ARGS.

Package

trivial-thumbnail.

Source

thumbnail.lisp.


5.2 Internals


Previous: , Up: Internals   [Contents][Index]

5.2.1 Ordinary functions

Function: binary-alternatives (binary-name)

Return a list of poissible alternative locations for the specified binary.

Package

trivial-thumbnail.

Source

thumbnail.lisp.

Function: locate-binary (label &rest alternatives)

Iterates through the alternatives and, if one can be found by PROBE-FILE, sets the SYMBOL-VALUE of LABEL to that path. Otherwise signals a WARNING.

Package

trivial-thumbnail.

Source

thumbnail.lisp.

Function: run-program (&rest argslist)

Wrapper around UIOP:RUN-PROGRAM that returns the string output of the command and
passes the argslist to UIOP:ESCAPE-COMMAND. Also accepts a pathname as the executable designator.

Package

trivial-thumbnail.

Source

thumbnail.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts