mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-02 11:05:29 -04:00
TMI-JPEG-4: Fixed issue related to X/Y density out of range.
This commit is contained in:
parent
bf1aae6652
commit
ae58b859e4
@ -88,8 +88,8 @@ final class JPEGImage10MetadataCleaner {
|
||||
jfif.setAttribute("majorVersion", String.valueOf(jfifSegment.majorVersion));
|
||||
jfif.setAttribute("minorVersion", String.valueOf(jfifSegment.minorVersion));
|
||||
jfif.setAttribute("resUnits", String.valueOf(jfifSegment.units));
|
||||
jfif.setAttribute("Xdensity", String.valueOf(jfifSegment.xDensity));
|
||||
jfif.setAttribute("Ydensity", String.valueOf(jfifSegment.yDensity));
|
||||
jfif.setAttribute("Xdensity", String.valueOf(Math.max(1, jfifSegment.xDensity))); // Avoid 0 density
|
||||
jfif.setAttribute("Ydensity", String.valueOf(Math.max(1,jfifSegment.yDensity)));
|
||||
jfif.setAttribute("thumbWidth", String.valueOf(jfifSegment.xThumbnail));
|
||||
jfif.setAttribute("thumbHeight", String.valueOf(jfifSegment.yThumbnail));
|
||||
|
||||
|
@ -55,7 +55,6 @@ import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@ -639,6 +638,16 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXDensityOutOfRangeIssue() throws IOException {
|
||||
// Image has JFIF with x/y density 0
|
||||
JPEGImageReader reader = createReader();
|
||||
reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/xdensity-out-of-range-zero.jpg")));
|
||||
|
||||
IIOMetadata imageMetadata = reader.getImageMetadata(0);
|
||||
assertNotNull(imageMetadata);
|
||||
}
|
||||
|
||||
// TODO: Test RGBA/YCbCrA handling
|
||||
|
||||
@Test
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 228 KiB |
Loading…
x
Reference in New Issue
Block a user