Configuration
P4Thumb supports the following modes:
- Built-in conversions of Qt-supported image formats
- Overwriting or extending of built-in formats with custom conversions
The following sections describe these formats.
Built-in conversions of Qt-supported image formats
To support this mode, you need to provide a configuration file that defines all settings needed to run P4Thumb.
The following code snippet is a configuration template for supporting built-in formats only:
{
"settings": {
"connection": {
"client": “<workspace name>“,
"port": “<server:port>“,
"user": “<thumbnail user>”
},
"logFile": “<path to log file>”,
"nativeSize": {
"height": <number of pixels default=160>,
"width": <number of pixels default=160>
},
"pollInterval": <number of seconds default=30>,
"maxFileSize" : <size in bytes default no-limit>
}
}
This configuration only includes the mandatory 'settings' block. You find an explanation of the settings after the following example of a configuration file that adds customized conversions using 3rd party tools of your choice.
Overwriting or extending of built-in formats
To create thumbnails, you can use external tools, such as ImageMagick, XnConvert, TinyPng, Imagine, or Image Tuner, provided the generated thumbnails are in a format supported by Qt and stored as PNG files in Helix Core server.
Using an external tool requires that you register a conversion for a set of file extensions. A conversion defines the executable to be called and the parameters required to perform the transformation/resizing. If a revision's file extension matches a registered file extension, P4Thumb uses the conversion to generate a thumbnail.
P4Thumb delivers the following example configuration files:
- thumbconfig.json: Uses ImageMacgick and Ghostscript to extend P4Thumb for chosen extensions on Linux
- winconfig.json: Uses XnView on Windows
You can also use your own tool to do the conversion for you. The only requirement is that you provide $FILEIN and $FILEOUT as parameters. P4Thumb provides the value for $FILEIN (revision) and $FILEOUT (thumb).
The following code snippet is a configuration template:
{
"settings": {
"connection": {
"client": “<workspace name>“,
"port": “<server:port>“,
"user": “<thumbnail user>”
},
"logFile": “<path to log file>”,
"nativeSize": {
"height": <number of pixels default=160>,
"width": <number of pixels default=160>
},
"pollInterval": <number of seconds default=30>,
"maxFileSize" : <size in bytes default no-limit>
},
"conversions": [
{
"extensions": [
<file extension>,
<file extension>
],
"execPath": "<CONVERSION EXECUTABLE>",
"arguments": [
“<argument>”,
“<argument>“,
"$FILEIN",
"$FILEOUT"
],
convertToPng": <true/false default=true>,
"thumbnailExtension": <file extension>
}
]
}
Configuration blocks
A configuration includes the following blocks:
- Settings: Mandatory.
- Conversions: Optional. Only to be used when using P4Thumb for non-Qt formats.
The following table describes the available parameters.
Parameter | Description |
---|---|
settings::connection |
The Helix Core connection and client used by P4Thumb. |
settings::logFile |
Optional. The log file used to output P4Thumb operations. |
settings::nativeSize |
Optional. Specifies the size of thumbnails. By default (if not set), the thumbnail size of Qt formats is 160x160 pixels. |
settings::pollinterval |
Specifies how often P4Thumb polls the server for changes. By default (if not set), polling happens every 30 seconds. |
settings::maxFileSize |
If set, P4Thumb only creates thumbnails for revisions below the specified maximum size (in bytes). If not set, P4Thumb creates a thumbnail for every file, assuming it presents a supported format. |
conversions:extensions |
The file extensions handled by this conversion. |
conversions::execPath |
The executable being called. |
conversion::arguments |
The arguments needed. $FILEIN and $FILEOUT are required. P4Thumb uses them as variables. |
conversion::convertToPng |
Optional. If set to false (default), the thumbail extension is .png. If set to true because the conversion program cannot convert to .png, P4Thumb uses the thumbnail extension specified. |
conversion::thumbnailExtension |
Optional. When convertToPng is set to true and this parameter is not set, the thumbnail extension is the source extension. Otherwise, if this parameter is set, the thumbnail extension is used. The generated %FILEOUT% now has the specified extension, such as .jpg. Note
The thumbnail extension needs to be a format supported by Qt. P4Thumb loads the file, converts it to .png, and saves it as a .png thumbnail. |
Testing conversion definitions
It is a good idea to test conversion definitions first, without adding thumbnail attributes to file revisions. The following command executes the conversion and writes the result to a local file:
$ p4thumb -c <config file> -test <file name>
For example, to test the following conversion:
{
"extensions": [
"gif",
"tif",
"tiff"
],
"execPath": "/usr/bin/convert",
"arguments": [
"-resize",
"160x160",
"$FILEIN[0]",
"$FILEOUT"
]
},
You can run the following command:
$ p4thumb -c config.json -test images/gmarbles.tif
If the conversion succeeds, the result is similar to the following:
== executing command:
"/usr/bin/convert" -resize 160x160 "/home/thumbuser/images/gmarbles.tif[0]" "/home/thumbuser/images/p4thumbs/gmarbles.png"
== Conversion successful
The output file, p4thumbs/gmarbles.png, indicates the accuracy of the thumbnail result when P4Thumb uses this conversion.
If the conversion fails, it results in the following:
'== Conversion successful' state '== error'
You can use the executing command to test and then correct conversions until all conversions succeed. At that point, the configuration file is ready to be used by P4Thumb to create thumbnails.
Your search for returned result(s).