You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2023/01/12 21:04:24 UTC

[GitHub] [commons-imaging] garydgregory commented on a diff in pull request #254: [IMAGING-339] Basic WebP Support

garydgregory commented on code in PR #254:
URL: https://github.com/apache/commons-imaging/pull/254#discussion_r1068651074


##########
src/main/java/org/apache/commons/imaging/formats/webp/chunks/WebPChunk.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.imaging.formats.webp.chunks;
+
+import org.apache.commons.imaging.ImageReadException;
+import org.apache.commons.imaging.common.BinaryFileParser;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.ByteOrder;
+import java.nio.charset.StandardCharsets;
+
+public abstract class WebPChunk extends BinaryFileParser {
+    public static final int TYPE_VP8 = 0x20385056;
+    public static final int TYPE_VP8L = 0x4C385056;
+    public static final int TYPE_VP8X = 0x58385056;
+    public static final int TYPE_ANIM = 0x4D494E41;
+    public static final int TYPE_ANMF = 0x464D4E41;
+    public static final int TYPE_ICCP = 0x50434349;
+    public static final int TYPE_EXIF = 0x46495845;
+    public static final int TYPE_XMP = 0x20504D58;
+
+    private final int type;
+    private final int size;
+    protected final byte[] bytes;
+
+    WebPChunk(int type, int size, byte[] bytes) throws ImageReadException {
+        super(ByteOrder.LITTLE_ENDIAN);
+
+        if (size != bytes.length) {
+            throw new AssertionError("Chunk size must match bytes length");

Review Comment:
   You must be thinking of IllegalStateException, we should not throw Errors.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org