Commit 5076c28b authored by Arent-Jan Banck's avatar Arent-Jan Banck Committed by Ate Douma

CMS-11148 Update drewnoakes-extractor from 2.6.2 to 2.11.0 (backported from CMS-11084)

The library is used to verify an jpg is using YCCK. Note that ImageMetaData has been deprecated some versions ago so should be scheduled for removal.

(cherry picked from commit 8e0a8789)
parent 638ddc89
......@@ -19,7 +19,9 @@ package org.hippoecm.frontend.plugins.gallery.imageutil;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.jcr.Binary;
import javax.jcr.Node;
......@@ -37,7 +39,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.drew.imaging.jpeg.JpegProcessingException;
import com.drew.imaging.jpeg.JpegSegmentData;
import com.drew.imaging.jpeg.JpegSegmentReader;
import com.drew.imaging.jpeg.JpegSegmentType;
import com.drew.lang.StreamReader;
/**
* This class extends a {@link Binary} class with extra information regarding images: filename, mimetype and
......@@ -157,10 +162,12 @@ public class ImageBinary implements Binary {
private boolean isYCCK() throws RepositoryException {
InputStream stream = getStream();
try {
JpegSegmentReader reader = new JpegSegmentReader(stream, false);
byte[] appe = reader.readSegment(JpegSegmentReader.SEGMENT_APPE);
Set<JpegSegmentType> segmentTypes = new HashSet<>();
segmentTypes.add(JpegSegmentType.APPE);
JpegSegmentData segmentData = JpegSegmentReader.readSegments(new StreamReader(stream), segmentTypes);
byte[] appe = segmentData.getSegment(JpegSegmentType.APPE);
return appe != null && appe[11] == 2;
} catch (JpegProcessingException e1) {
} catch (IOException | JpegProcessingException e1) {
log.warn("Unable to read color space", e1);
} finally {
IOUtils.closeQuietly(stream);
......
/*
* Copyright 2012-2015 Hippo B.V. (http://www.onehippo.com)
* Copyright 2012-2018 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -19,7 +19,9 @@ package org.hippoecm.frontend.plugins.gallery.imageutil;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.commons.io.IOUtils;
import org.apache.sanselan.ImageInfo;
......@@ -31,7 +33,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.drew.imaging.jpeg.JpegProcessingException;
import com.drew.imaging.jpeg.JpegSegmentData;
import com.drew.imaging.jpeg.JpegSegmentReader;
import com.drew.imaging.jpeg.JpegSegmentType;
import com.drew.lang.StreamReader;
/**
* Provides meta-data about an image: its color model, MIME type, and file name.
......@@ -109,8 +114,10 @@ public class ImageMetaData implements IClusterable {
private boolean isYCCK(final ReusableInputStream ris) throws IOException {
try {
JpegSegmentReader reader = new JpegSegmentReader(ris, false);
byte[] appe = reader.readSegment(JpegSegmentReader.SEGMENT_APPE);
Set<JpegSegmentType> segmentTypes = new HashSet<>();
segmentTypes.add(JpegSegmentType.APPE);
JpegSegmentData segmentData = JpegSegmentReader.readSegments(new StreamReader(ris), segmentTypes);
byte[] appe = segmentData.getSegment(JpegSegmentType.APPE);
return appe != null && appe[11] == 2;
} catch (JpegProcessingException e1) {
log.warn("Unable to read color space", e1);
......
......@@ -120,7 +120,7 @@
<joda-time.version>2.0</joda-time.version>
<json-lib.version>2.4</json-lib.version>
<drewnoakes-extractor.version>2.6.2</drewnoakes-extractor.version>
<drewnoakes-extractor.version>2.11.0</drewnoakes-extractor.version>
<sanselan.version>0.97-incubator</sanselan.version>
<agilecoders.wicket.bootstrap.version>0.9.7</agilecoders.wicket.bootstrap.version>
<imgscalr-lib.version>4.2</imgscalr-lib.version>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment