Skip to content

Commit dfc7091

Browse files
committed
add test files after reverting of 7.0 GIF frames are of ImageType GIF
GIF frames are of ImageType GIF this way the following code acts as expected: assertEquals(ImageType.GIF, ImageDataFactory.create(GIF_FILE_AS_BYTE_ARRAY).getOriginalType()); Codepath: 1. com.itextpdf.io.image.ImageDataFactory.createImageInstance(byte[], boolean) uses GifImageHelper.processImage(image, 0); to read first GIF Frame 2. first Frame is returned via image.getFrames().get(0) format test class GifTest Revert "GIF frames are of ImageType GIF" This reverts commit af848c4. GIF frames are of ImageType GIF this way the following code acts as expected: assertEquals(ImageType.GIF, ImageDataFactory.create(GIF_FILE_AS_BYTE_ARRAY).getOriginalType()); Codepath: 1. com.itextpdf.io.image.ImageDataFactory.createImageInstance(byte[], boolean) uses GifImageHelper.processImage(image, 0); to read first GIF Frame 2. first Frame is returned via image.getFrames().get(0)
1 parent 62211e8 commit dfc7091

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

io/src/main/java/com/itextpdf/io/image/GifImageHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ private static void readFrame(GifParameters gif) throws java.io.IOException {
303303
colorspace[3] = PdfEncodings.convertToString(gif.m_curr_table, null);
304304
Map<String, Object> ad = new HashMap<>();
305305
ad.put("ColorSpace", colorspace);
306-
RawImageData img = new RawImageData(gif.m_out, ImageType.NONE);
306+
RawImageData img = new RawImageData(gif.m_out, ImageType.GIF);
307307
RawImageHelper.updateRawImageParameters(img, gif.iw, gif.ih, 1, gif.m_bpc, gif.m_out);
308308
RawImageHelper.updateImageAttributes(img, ad);
309309
gif.image.addFrame(img);
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2018 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License version 3
8+
as published by the Free Software Foundation with the addition of the
9+
following permission added to Section 15 as permitted in Section 7(a):
10+
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
11+
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
12+
OF THIRD PARTY RIGHTS
13+
14+
This program is distributed in the hope that it will be useful, but
15+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16+
or FITNESS FOR A PARTICULAR PURPOSE.
17+
See the GNU Affero General Public License for more details.
18+
You should have received a copy of the GNU Affero General Public License
19+
along with this program; if not, see http://www.gnu.org/licenses or write to
20+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21+
Boston, MA, 02110-1301 USA, or download the license from the following URL:
22+
http://itextpdf.com/terms-of-use/
23+
24+
The interactive user interfaces in modified source and object code versions
25+
of this program must display Appropriate Legal Notices, as required under
26+
Section 5 of the GNU Affero General Public License.
27+
28+
In accordance with Section 7(b) of the GNU Affero General Public License,
29+
a covered work must retain the producer line in every PDF that is created
30+
or manipulated using iText.
31+
32+
You can be released from the requirements of the license by purchasing
33+
a commercial license. Buying such a license is mandatory as soon as you
34+
develop commercial activities involving the iText software without
35+
disclosing the source code of your own applications.
36+
These activities include: offering paid services to customers as an ASP,
37+
serving PDFs on the fly in a web application, shipping iText with a closed
38+
source product.
39+
40+
For more information, please contact iText Software Corp. at this
41+
42+
*/
43+
44+
package com.itextpdf.io.image;
45+
46+
import com.itextpdf.io.util.StreamUtil;
47+
import com.itextpdf.test.annotations.type.UnitTest;
48+
import org.junit.Assert;
49+
import org.junit.Test;
50+
import org.junit.experimental.categories.Category;
51+
52+
import java.io.FileInputStream;
53+
import java.io.IOException;
54+
@Category(UnitTest.class)
55+
public class GifTest {
56+
public static final String sourceFolder = "./src/test/resources/com/itextpdf/io/image/";
57+
58+
@Test
59+
public void gifImageTest() throws IOException {
60+
byte[] fileContent = StreamUtil.inputStreamToArray( new FileInputStream( sourceFolder+"WP_20140410_001.gif" ) );
61+
ImageData img = ImageDataFactory.create( fileContent, false );
62+
Assert.assertTrue( img.isRawImage() );
63+
Assert.assertEquals( ImageType.GIF, img.getOriginalType() );
64+
65+
}
66+
}
1.45 MB
Loading

0 commit comments

Comments
 (0)