diff --git a/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/ImagingComponent.java b/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/ImagingComponent.java index b2ea2e3f085..2eb9c18fe2d 100644 --- a/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/ImagingComponent.java +++ b/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/ImagingComponent.java @@ -177,7 +177,7 @@ public class ImagingComponent extends DefaultComponent implements ImagingService try { String ext = blob.getFilename() == null ? ".tmp" : "." + FilenameUtils.getExtension(blob.getFilename()); try (CloseableFile cf = blob.getCloseableFile(ext)) { - imageInfo = ImageIdentifier.getInfo(cf.getFile().getCanonicalPath()); + imageInfo = ImageIdentifier.getInfo(cf.getFile().getCanonicalPath(), ext); } } catch (CommandNotAvailable | CommandException e) { log.error("Failed to get ImageInfo for file " + blob.getFilename(), e); diff --git a/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/core/im/IMImageUtils.java b/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/core/im/IMImageUtils.java index 2f800832294..5cb28a8e0b3 100644 --- a/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/core/im/IMImageUtils.java +++ b/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/core/im/IMImageUtils.java @@ -89,7 +89,7 @@ public class IMImageUtils implements ImageUtils { sourceFile = createTempSource(blob, "tmp"); } // detect extension - ext = ImageIdentifier.getInfo(sourceFile.getPath()).getFormat(); + ext = ImageIdentifier.getInfo(sourceFile.getPath(), ext).getFormat(); if (tmpFile == null) { // copy source with proper name sourceFile = createTempSource(blob, ext); diff --git a/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/magick/utils/ImageIdentifier.java b/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/magick/utils/ImageIdentifier.java index 3fd76654b7a..7edb4181ca6 100644 --- a/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/magick/utils/ImageIdentifier.java +++ b/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/java/org/nuxeo/ecm/platform/picture/magick/utils/ImageIdentifier.java @@ -41,8 +41,12 @@ public class ImageIdentifier extends MagickExecutor { private static final Log log = LogFactory.getLog(ImageIdentifier.class); public static ImageInfo getInfo(String inputFilePath) throws CommandNotAvailable, CommandException { + return getInfo(inputFilePath, null); + } + + public static ImageInfo getInfo(String inputFilePath, String ext) throws CommandNotAvailable, CommandException { - ExecResult result = getIdentifyResult(inputFilePath); + ExecResult result = getIdentifyResult(inputFilePath, ext); if (!result.isSuccessful()) { log.debug("identify failed for file: " + inputFilePath); throw result.getError(); @@ -53,10 +57,18 @@ public class ImageIdentifier extends MagickExecutor { return new ImageInfo(res[1], res[2], res[0], res[3], res[4], inputFilePath); } - public static ExecResult getIdentifyResult(String inputFilePath) throws CommandNotAvailable { + public static ExecResult getIdentifyResult(String inputFilePath, String extension) throws CommandNotAvailable { CommandLineExecutorService cles = Framework.getService(CommandLineExecutorService.class); CmdParameters params = cles.getDefaultCmdParameters(); params.addNamedParameter("inputFilePath", inputFilePath); + if (extension != null && !"".equals(extension.trim())) { + if (extension.startsWith(".")) { + extension = extension.substring(1); + } + params.addNamedParameter("inputExtension", extension + ":"); + } else { + params.addNamedParameter("inputExtension", ""); + } return cles.execCommand("identify", params); } diff --git a/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/resources/OSGI-INF/commandline-imagemagick-contrib.xml b/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/resources/OSGI-INF/commandline-imagemagick-contrib.xml index 97cbe6b6b12..d516ba5520b 100644 --- a/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/resources/OSGI-INF/commandline-imagemagick-contrib.xml +++ b/nuxeo-features/nuxeo-platform-imaging/nuxeo-platform-imaging-core/src/main/resources/OSGI-INF/commandline-imagemagick-contrib.xml @@ -8,8 +8,8 @@ identify - -define registry:temporary-path=#{nuxeo.tmp.dir} -quiet -ping -format '%m %w %h %z %[colorspace]' #{inputFilePath}[0] - -define registry:temporary-path=#{nuxeo.tmp.dir} -quiet -ping -format "%m %w %h %z %[colorspace]" #{inputFilePath}[0] + -define registry:temporary-path=#{nuxeo.tmp.dir} -quiet -ping -format '%m %w %h %z %[colorspace]' #{inputExtension}#{inputFilePath}[0] + -define registry:temporary-path=#{nuxeo.tmp.dir} -quiet -ping -format "%m %w %h %z %[colorspace]" #{inputExtension}#{inputFilePath}[0] You need to install ImageMagick.