The ImageMagick Media Filters provide consistent, high quality thumbnails for image bitstreams and PDF bitstreams.
These filters require a separate software installation of the conversion utilities (ImageMagick and Ghostscript).
The media filters use the library im4java to invoke the conversion utilities. This library constructs a conversion command launches a sub-process to perform the generation of media files.
In the filter.plugins section of your dspace.cfg file, uncomment the ImageMagick media filter definition.
ImageMagick Image Thumbnail, ImageMagick PDF Thumbnail, \
This will activate the following settings which are already present in dspace.cfg:
org.dspace.app.mediafilter.ImageMagickImageThumbnailFilter = ImageMagick Image Thumbnail, \ org.dspace.app.mediafilter.ImageMagickPdfThumbnailFilter = ImageMagick PDF Thumbnail
These media filters contain the several properties which can be configured.
The following properties are used to define the dimensions of the generated thumbnails:
# maximum width and height of generated thumbnails thumbnail.maxwidth = 80 thumbnail.maxheight = 80
The following property provides a path to the ImageMagick and GhostScript utilities.
org.dspace.app.mediafilter.ImageMagickThumbnailFilter.ProcessStarter = /usr/bin
The ImageMagick media filters can differentiate thumbnails created by the DSpace default thumbnail generator and thumbnails that were manually uploaded by a user. The media filter reads the bitstream description field to make this determination. A regular expression can be provided to define the set of thumbnails that should be overwritten by the ImageMagick thumbnail generator. Thumbnail descriptions matching this pattern will be overwritten even if the -f option is not passed to the filter media process.
org.dspace.app.mediafilter.ImageMagickThumbnailFilter.replaceRegex = ^Generated Thumbnail$
The ImageMagick media filter will use the bitstream description field to identify bitstreams that it has created using the following setting. Bitstreams containing this label will be overwritten only if the -f filter is applied.
org.dspace.app.mediafilter.ImageMagickThumbnailFilter.bitstreamDescription = IM Thumbnail
Thumbnail descriptions that do not match either of the patterns listed above are presumed to be manually uploaded thumbnails. These thumbnails will not be replaced even if the -f option is passed to the filter media process.
DSpace uses the JPEG format for thumbnails. While JPEG doesn't support transparency, PDF, PNG and other formats do. As those formats are used as outgoing material in DSpace, DSpace has to care about transparency during the generation of the thumbnails. In combinations of specific versions of ImageMagick and Ghostscript it may occur that completely transparent areas will become black. As a solution ImageMagick recommends to flatten images extracted from PDFs before they are stored as JPEG.
Since DSpace 5.2 the ImageMagick media filter flattens thumbnails extracted from PDFs. If you run into problems caused by flattening of the extracted images, you can switch the flattening off by setting the following property in dspace.cfg to false:
org.dspace.app.mediafilter.ImageMagickThumbnailFilter.flatten = false
PDFs optimized for physical printing often use the CMYK color space. On the web, however, the de facto color system is sRGB. By default, DSpace's ImageMagick-based thumbnailing system will create thumbnails that use the same color space as the source PDF. Most web browsers are not able to correctly display images that use the CMYK color space, which leads to images with visibly inaccurate colors. Furthermore, the JSPUI currently does not support the display of thumbnails that use the CMYK color space (see DS-2834).
If you are using Ghostscript version 9 or above, it is possible for DSpace to correctly convert images from CMYK to sRGB by providing it with appropriate ICC color profiles to use during thumbnail creation. Default ones are provided by most Ghostscript installations (version 9 or above). The following configuration options tell DSpace where those ICC profiles are located.
# org.dspace.app.mediafilter.ImageMagickThumbnailFilter.cmyk_profile = /usr/share/ghostscript/9.18/iccprofiles/default_cmyk.icc # org.dspace.app.mediafilter.ImageMagickThumbnailFilter.srgb_profile = /usr/share/ghostscript/9.18/iccprofiles/default_rgb.icc
You may need to adjust those paths for your OS or the version of Ghostscript that you have.
Providing ICC profiles to ImageMagick is optional. If these configuration properties are unset, no profiles will be supplied to ImageMagick, and thumbnails produced from PDFs using the CMYK color space will also use CMYK. The transformation from CMYK to RGB is optional, but keep in mind that thumbnails using CMYK will cause problems if you use JSPUI and display thumbnails on browse and search pages (see DS-2834).
The ImageMagick conversion software provides a large number of conversion options. Subclasses of these media filters could be written to take advantage of the additional conversion properties available in the software.
Note: The PDF thumbnail generator is hard-coded to generate a thumbnail from the first page of the PDF.
On Ubuntu (possibly other OSes), you may see errors like these when attempting to generate PDF thumbnails:
ERROR filtering, skipping bitstream: Item Handle: 1234/5678 Bundle Name: ORIGINAL File Size: 30406135 Checksum: c1df4b3a4755e9bed956383b61fc5042 (MD5) Asset Store: 0 org.im4java.core.CommandException: org.im4java.core.CommandException: convert.im6: not authorized `/tmp/impdfthumb6294641076817830415.pdf' @ error/constitute.c/ReadImage/454.
These may be caused by a change in your ImageMagick policy configuration on your server.
In Ubuntu, the default "policy.xml" was recently updated to exclude all Ghostscript formats (including PDF, PS, etc). See this ticket: https://bugs.launchpad.net/ubuntu/+source/imagemagick/+bug/1796563
The newly added lines in the
/etc/ImageMagick/policy.xml are these ones:
<!-- disable ghostscript format types --> <policy domain="coder" rights="none" pattern="PS" /> <policy domain="coder" rights="none" pattern="EPS" /> <policy domain="coder" rights="none" pattern="PDF" /> <policy domain="coder" rights="none" pattern="XPS" />
If you wish to re-enable ImageMagick to process Ghostscript format types, you can simply comment out those lines in the configuration file. Be aware that, as the fix to this vulnerability is not yet verified, you should only do so at your own risk.