mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
DS-3517 Allow improved handling of CMYK PDFs
Allow ImageMagick to generate thumbnails with more accurate colors for PDFs using the CMYK color system. This adds two options to the dspace.cfg where the user can optionally specify paths to CMYK and RGB color profiles if they are available on their system (they are provided by Ghostscript 9.x). Uses im4java's Info class to determine the color system being used by the PDF. See: http://im4java.sourceforge.net/docs/dev-guide.html
This commit is contained in:

committed by
Pascal-Nicolas Becker

parent
e16f6a80d5
commit
27255735c4
@@ -23,6 +23,7 @@ import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.im4java.core.ConvertCmd;
|
||||
import org.im4java.core.Info;
|
||||
import org.im4java.core.IM4JavaException;
|
||||
import org.im4java.core.IMOperation;
|
||||
import org.im4java.process.ProcessStarter;
|
||||
@@ -43,6 +44,9 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter
|
||||
static final String defaultPattern = "Generated Thumbnail";
|
||||
static Pattern replaceRegex = Pattern.compile(defaultPattern);
|
||||
protected final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
|
||||
static String cmyk_profile;
|
||||
static String srgb_profile;
|
||||
|
||||
static {
|
||||
String pre = ImageMagickThumbnailFilter.class.getName();
|
||||
@@ -52,6 +56,8 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter
|
||||
height = ConfigurationManager.getIntProperty("thumbnail.maxheight", height);
|
||||
flatten = ConfigurationManager.getBooleanProperty(pre + ".flatten", flatten);
|
||||
String description = ConfigurationManager.getProperty(pre + ".bitstreamDescription");
|
||||
cmyk_profile = ConfigurationManager.getProperty(pre + ".cmyk_profile");
|
||||
srgb_profile = ConfigurationManager.getProperty(pre + ".srgb_profile");
|
||||
if (description != null) {
|
||||
bitstreamDescription = description;
|
||||
}
|
||||
@@ -136,12 +142,19 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter
|
||||
f2.deleteOnExit();
|
||||
ConvertCmd cmd = new ConvertCmd();
|
||||
IMOperation op = new IMOperation();
|
||||
Info imageInfo = new Info(f.getAbsolutePath(),true);
|
||||
String s = "[" + page + "]";
|
||||
op.addImage(f.getAbsolutePath()+s);
|
||||
if (flatten)
|
||||
{
|
||||
op.flatten();
|
||||
}
|
||||
String imageClass = imageInfo.getImageClass();
|
||||
// PDFs using the CMYK color system can be handled specially if profiles are defined
|
||||
if (imageClass.contains("CMYK") && cmyk_profile != null && srgb_profile != null) {
|
||||
op.profile(cmyk_profile);
|
||||
op.profile(srgb_profile);
|
||||
}
|
||||
op.addImage(f2.getAbsolutePath());
|
||||
if (verbose) {
|
||||
System.out.println("IM Image Param: "+op);
|
||||
|
@@ -421,6 +421,13 @@ filter.org.dspace.app.mediafilter.PDFBoxThumbnail.inputFormats = Adobe PDF
|
||||
# next property false, if necessary for any reasons.
|
||||
# org.dspace.app.mediafilter.ImageMagickThumbnailFilter.flatten = true
|
||||
|
||||
# Optional: full paths to CMYK and sRGB color profiles. If present, will allow
|
||||
# ImageMagick to produce much more color accurate thumbnails for PDFs that are
|
||||
# using the CMYK color system. The default_cmyk.icc and default_rgb.icc profiles
|
||||
# provided by the system's Ghostscript (version 9.x) package are good choices.
|
||||
# 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
|
||||
|
||||
#### Crosswalk and Packager Plugin Settings ####
|
||||
# Crosswalks are used to translate external metadata formats into DSpace's internal format (DIM)
|
||||
# Packagers are used to ingest/export 'packages' (both content files and metadata)
|
||||
|
Reference in New Issue
Block a user