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 cf6a756d2855c71d99e47ea6a57b69f57ec90459 Author: Gary Gregory <[email protected]> AuthorDate: Sat Jan 3 12:17:22 2026 -0500 Javadoc --- .../formats/jpeg/JpegPhotoshopMetadata.java | 12 ++++++++++++ .../imaging/formats/jpeg/xmp/JpegXmpParser.java | 16 ++++++++++++++++ .../imaging/internal/ImageParserFactory.java | 22 ++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegPhotoshopMetadata.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegPhotoshopMetadata.java index 9c657265..b68150c3 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegPhotoshopMetadata.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegPhotoshopMetadata.java @@ -24,10 +24,19 @@ import org.apache.commons.imaging.formats.jpeg.iptc.IptcTypes; import org.apache.commons.imaging.formats.jpeg.iptc.PhotoshopApp13Data; import org.apache.commons.imaging.internal.Debug; +/** + * Metadata extracted from Photoshop APP13 segment in JPEG images. + */ public class JpegPhotoshopMetadata extends GenericImageMetadata { + /** The Photoshop APP13 data. */ public final PhotoshopApp13Data photoshopApp13Data; + /** + * Constructs metadata from Photoshop APP13 data. + * + * @param photoshopApp13Data the Photoshop APP13 data. + */ public JpegPhotoshopMetadata(final PhotoshopApp13Data photoshopApp13Data) { this.photoshopApp13Data = photoshopApp13Data; @@ -40,6 +49,9 @@ public class JpegPhotoshopMetadata extends GenericImageMetadata { } } + /** + * Dumps the metadata to debug output. + */ public void dump() { Debug.debug(this.toString()); } diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java index d3ffb240..ea399892 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java @@ -23,6 +23,9 @@ import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.common.BinaryFileParser; import org.apache.commons.imaging.formats.jpeg.JpegConstants; +/** + * Parses XMP metadata in JPEG images. + */ public class JpegXmpParser extends BinaryFileParser { /** @@ -32,10 +35,23 @@ public class JpegXmpParser extends BinaryFileParser { // empty } + /** + * Checks if the segment data contains XMP metadata. + * + * @param segmentData the segment data. + * @return true if this is an XMP segment, false otherwise. + */ public boolean isXmpJpegSegment(final byte[] segmentData) { return JpegConstants.XMP_IDENTIFIER.isStartOf(segmentData); } + /** + * Parses XMP metadata from a JPEG segment. + * + * @param segmentData the segment data. + * @return the XMP metadata as a string. + * @throws ImagingException if the segment is not a valid XMP segment. + */ public String parseXmpJpegSegment(final byte[] segmentData) throws ImagingException { if (!isXmpJpegSegment(segmentData)) { throw new ImagingException("Invalid JPEG XMP Segment."); diff --git a/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java b/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java index 70438759..c180eed1 100644 --- a/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java +++ b/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java @@ -35,6 +35,14 @@ import org.apache.commons.imaging.bytesource.ByteSource; */ public final class ImageParserFactory { + /** + * Gets an image parser for the given byte source. + * + * @param <T> the imaging parameters type. + * @param byteSource the byte source. + * @return the image parser. + * @throws IOException if an I/O error occurs. + */ public static <T extends ImagingParameters<T>> AbstractImageParser<T> getImageParser(final ByteSource byteSource) throws IOException { // TODO: circular dependency between Imaging and internal Util class below. final ImageFormat format = Imaging.guessFormat(byteSource); @@ -48,6 +56,13 @@ public final class ImageParserFactory { throw new IllegalArgumentException("Can't parse this format."); } + /** + * Gets an image parser for the given image format. + * + * @param <T> the imaging parameters type. + * @param format the image format. + * @return the image parser. + */ public static <T extends ImagingParameters<T>> AbstractImageParser<T> getImageParser(final ImageFormat format) { return getImageParser(parser -> parser.canAcceptType(format), () -> new IllegalArgumentException("Unknown ImageFormat: " + format)); } @@ -60,6 +75,13 @@ public final class ImageParserFactory { return (AbstractImageParser<T>) AbstractImageParser.getAllImageParsers().stream().filter(pred).findFirst().orElseThrow(supplier); } + /** + * Gets an image parser for the given file extension. + * + * @param <T> the imaging parameters type. + * @param fileExtension the file extension. + * @return the image parser. + */ public static <T extends ImagingParameters<T>> AbstractImageParser<T> getImageParser(final String fileExtension) { return getImageParser(parser -> parser.canAcceptExtension(fileExtension), () -> new IllegalArgumentException("Unknown extension: " + fileExtension)); }
