Analysers
An Analyser analyses a particular property of a piece of content, e.g. the width of an image, the bitrate of an audio file, etc.
One can be added using a block
or providing an object that responds to call
(MyAnalyser
in this case)
Using the analyser
The analyser is available as a method to Job
objects
and Attachment
objects
Implementing the analyser
The content
object yielded to the block/call
method is a Dragonfly::Content - see the doc for methods it provides.
Returning the property
Simply return the calculated property. You will probably want to use one of the Content
methods for getting the data such as data
(String), file
, path
, etc.
Using shell commands
To use the shell, you can use Content#shell_eval
The yielded path
above will always exist.
Using pre-registered analysers
To use a pre-registered analyser, use Content#analyse
ImageMagick
The ImageMagick plugin adds a few analysers - see the doc for more details.
“Magic” Model Attributes
To automatically store analysed properties in your model see Models - Magic Attributes
Derived from theme by orderedlist