[ https://issues.apache.org/jira/browse/IMAGING-339?focusedWorklogId=838954&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-838954 ]
ASF GitHub Bot logged work on IMAGING-339: ------------------------------------------ Author: ASF GitHub Bot Created on: 12/Jan/23 21:12 Start Date: 12/Jan/23 21:12 Worklog Time Spent: 10m Work Description: Glavo commented on code in PR #254: URL: https://github.com/apache/commons-imaging/pull/254#discussion_r1068659362 ########## 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. In my understanding, here I am asserting that throwing an exception is an unreachable path. But I thought again, maybe it is also feasible to throw `IllegalArgumentException`, because Chunk may also be constructed by users themselves. Issue Time Tracking ------------------- Worklog Id: (was: 838954) Time Spent: 50m (was: 40m) > Basic WebP support > ------------------ > > Key: IMAGING-339 > URL: https://issues.apache.org/jira/browse/IMAGING-339 > Project: Commons Imaging > Issue Type: Improvement > Components: Format: WebP > Affects Versions: 1.0-alpha2 > Reporter: Bruno P. Kinoshita > Assignee: Bruno P. Kinoshita > Priority: Minor > Fix For: 1.0-alpha3 > > Time Spent: 50m > Remaining Estimate: 0h > > Placeholder for https://github.com/apache/commons-imaging/pull/254 -- This message was sent by Atlassian Jira (v8.20.10#820010)