This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
commit 4834111a4bfeb38692051a2d970df2e7fa1ebf29 Author: Gary Gregory <[email protected]> AuthorDate: Sat Jan 3 10:59:06 2026 -0500 Javadoc --- .../apache/commons/imaging/ImagingParameters.java | 44 ++++++++++++++++++++++ .../commons/imaging/common/ImageMetadata.java | 23 +++++++++++ .../imaging/formats/jpeg/segments/JfifSegment.java | 41 +++++++++++++++++--- 3 files changed, 103 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/commons/imaging/ImagingParameters.java b/src/main/java/org/apache/commons/imaging/ImagingParameters.java index dc86410a..ba4ecdc5 100644 --- a/src/main/java/org/apache/commons/imaging/ImagingParameters.java +++ b/src/main/java/org/apache/commons/imaging/ImagingParameters.java @@ -69,37 +69,81 @@ public class ImagingParameters<E extends ImagingParameters<E>> { return (E) this; } + /** + * Gets the buffered image factory. + * + * @return the buffered image factory, or null if not set. + */ public BufferedImageFactory getBufferedImageFactory() { return bufferedImageFactory; } + /** + * Gets the file name. + * + * @return the file name, or null if not set. + */ public String getFileName() { return fileName; } + /** + * Gets the pixel density. + * + * @return the pixel density, or null if not set. + */ public PixelDensity getPixelDensity() { return pixelDensity; } + /** + * Gets whether strict mode is enabled. + * + * @return true if strict mode is enabled, false otherwise. + */ public boolean isStrict() { return strict; } + /** + * Sets the buffered image factory. + * + * @param bufferedImageFactory the buffered image factory. + * @return this instance. + */ public E setBufferedImageFactory(final BufferedImageFactory bufferedImageFactory) { this.bufferedImageFactory = bufferedImageFactory; return asThis(); } + /** + * Sets the file name. + * + * @param fileName the file name. + * @return this instance. + */ public E setFileName(final String fileName) { this.fileName = fileName; return asThis(); } + /** + * Sets the pixel density. + * + * @param pixelDensity the pixel density. + * @return this instance. + */ public E setPixelDensity(final PixelDensity pixelDensity) { this.pixelDensity = pixelDensity; return asThis(); } + /** + * Sets whether strict mode is enabled. + * + * @param strict true to enable strict mode, false otherwise. + * @return this instance. + */ public E setStrict(final boolean strict) { this.strict = strict; return asThis(); diff --git a/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java b/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java index 1c914206..1d0f0a5f 100644 --- a/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java +++ b/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java @@ -18,15 +18,38 @@ package org.apache.commons.imaging.common; import java.util.List; +/** + * Image metadata. + */ public interface ImageMetadata { + /** + * Represents a single metadata item. + */ interface ImageMetadataItem { @Override String toString(); + /** + * Gets a string representation with a prefix. + * + * @param prefix the prefix to use. + * @return the string representation. + */ String toString(String prefix); } + /** + * Gets the list of metadata items. + * + * @return the list of metadata items. + */ List<? extends ImageMetadataItem> getItems(); + /** + * Gets a string representation with a prefix. + * + * @param prefix the prefix to use. + * @return the string representation. + */ String toString(String prefix); } diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java index b67a0d43..78f925fc 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegment.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.commons.imaging.formats.jpeg.segments; import static org.apache.commons.imaging.common.BinaryFunctions.read2Bytes; @@ -28,41 +29,72 @@ import java.io.InputStream; import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.formats.jpeg.JpegConstants; +/** + * A JFIF (JPEG File Interchange Format) segment. + */ public final class JfifSegment extends AbstractSegment { + + /** JFIF major version number. */ public final int jfifMajorVersion; + + /** JFIF minor version number. */ public final int jfifMinorVersion; + + /** Density units (0 = no units, 1 = pixels per inch, 2 = pixels per cm). */ public final int densityUnits; + + /** Horizontal pixel density. */ public final int xDensity; + + /** Vertical pixel density. */ public final int yDensity; + /** Thumbnail width in pixels. */ public final int xThumbnail; + + /** Thumbnail height in pixels. */ public final int yThumbnail; + + /** Thumbnail size in bytes. */ public final int thumbnailSize; + /** + * Constructs a new JFIF segment from segment data. + * + * @param marker the segment marker. + * @param segmentData the segment data bytes. + * @throws ImagingException if an imaging error occurs. + * @throws IOException if an I/O error occurs. + */ public JfifSegment(final int marker, final byte[] segmentData) throws ImagingException, IOException { this(marker, segmentData.length, new ByteArrayInputStream(segmentData)); } + /** + * Constructs a new JFIF segment from an input stream. + * + * @param marker the segment marker. + * @param markerLength the marker length. + * @param is the input stream. + * @throws ImagingException if an imaging error occurs. + * @throws IOException if an I/O error occurs. + */ public JfifSegment(final int marker, final int markerLength, final InputStream is) throws ImagingException, IOException { super(marker, markerLength); - final byte[] signature = readBytes(is, JpegConstants.JFIF0_SIGNATURE.size()); if (!JpegConstants.JFIF0_SIGNATURE.equals(signature) && !JpegConstants.JFIF0_SIGNATURE_ALTERNATIVE.equals(signature)) { throw new ImagingException("Not a Valid JPEG File: missing JFIF string"); } - jfifMajorVersion = readByte("jfifMajorVersion", is, "Not a Valid JPEG File"); jfifMinorVersion = readByte("jfifMinorVersion", is, "Not a Valid JPEG File"); densityUnits = readByte("densityUnits", is, "Not a Valid JPEG File"); xDensity = read2Bytes("xDensity", is, "Not a Valid JPEG File", getByteOrder()); yDensity = read2Bytes("yDensity", is, "Not a Valid JPEG File", getByteOrder()); - xThumbnail = readByte("xThumbnail", is, "Not a Valid JPEG File"); yThumbnail = readByte("yThumbnail", is, "Not a Valid JPEG File"); thumbnailSize = xThumbnail * yThumbnail; if (thumbnailSize > 0) { skipBytes(is, thumbnailSize, "Not a Valid JPEG File: missing thumbnail"); - } } @@ -70,5 +102,4 @@ public final class JfifSegment extends AbstractSegment { public String getDescription() { return "JFIF (" + getSegmentType() + ")"; } - }
