Class JPGMeta

java.lang.Object
pixy.meta.jpeg.JPGMeta

public class JPGMeta
extends java.lang.Object
JPEG image tweaking tool
Version:
1.0 01/25/2013
Author:
Wen Yu, yuwen_66@yahoo.com
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.util.EnumSet<Marker> APPnMarkers  
  • Method Summary

    Modifier and Type Method Description
    static void extractDepthMap​(java.io.InputStream is, java.lang.String pathToDepthMap)  
    static byte[] extractICCProfile​(java.io.InputStream is)  
    static void extractICCProfile​(java.io.InputStream is, java.lang.String pathToICCProfile)  
    static void extractThumbnails​(java.io.InputStream is, java.lang.String pathToThumbnail)
    Extracts thumbnail images from JFIF/APP0, Exif APP1 and/or Adobe APP13 segment if any.
    static ICCProfile getICCProfile​(java.io.InputStream is)  
    static void insertComments​(java.io.InputStream is, java.io.OutputStream os, java.util.List<java.lang.String> comments)  
    static void insertExif​(java.io.InputStream is, java.io.OutputStream os, Exif exif, boolean update)  
    static void insertICCProfile​(java.io.InputStream is, java.io.OutputStream os, byte[] data)
    Insert ICC_Profile as one or more APP2 segments
    static void insertICCProfile​(java.io.InputStream is, java.io.OutputStream os, java.awt.color.ICC_Profile icc_profile)  
    static void insertICCProfile​(java.io.InputStream is, java.io.OutputStream os, ICCProfile icc_profile)  
    static void insertIPTC​(java.io.InputStream is, java.io.OutputStream os, java.util.Collection<IPTCDataSet> iptcs, boolean update)
    Inserts a list of IPTCDataSet into a JPEG APP13 Photoshop IRB segment
    static void insertIRB​(java.io.InputStream is, java.io.OutputStream os, java.util.Collection<_8BIM> bims, boolean update)
    Inserts a collection of _8BIM into a JPEG APP13 Photoshop IRB segment
    static void insertIRBThumbnail​(java.io.InputStream is, java.io.OutputStream os, java.awt.image.BufferedImage thumbnail)  
    static void insertXMP​(java.io.InputStream is, java.io.OutputStream os, java.lang.String xmp, java.lang.String extendedXmp)
    Insert XMP into single APP1 or multiple segments.
    static void insertXMP​(java.io.InputStream is, java.io.OutputStream os, XMP xmp)
    Insert a XMP instance into the image.
    static java.util.Map<MetadataType,​Metadata> readMetadata​(java.io.InputStream is)  
    static void removeAPPn​(Marker APPn, java.io.InputStream is, java.io.OutputStream os)  
    static java.util.Map<MetadataType,​Metadata> removeMetadata​(java.io.InputStream is, java.io.OutputStream os, MetadataType... metadataTypes)
    Removes metadata specified by the input MetadataType set.
    static java.util.Map<MetadataType,​Metadata> removeMetadata​(java.util.Set<MetadataType> metadataTypes, java.io.InputStream is, java.io.OutputStream os)
    Removes metadata specified by the input MetadataType set.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • extractICCProfile

      public static byte[] extractICCProfile​(java.io.InputStream is) throws java.io.IOException
      Throws:
      java.io.IOException
    • extractICCProfile

      public static void extractICCProfile​(java.io.InputStream is, java.lang.String pathToICCProfile) throws java.io.IOException
      Throws:
      java.io.IOException
    • extractDepthMap

      public static void extractDepthMap​(java.io.InputStream is, java.lang.String pathToDepthMap) throws java.io.IOException
      Throws:
      java.io.IOException
    • extractThumbnails

      public static void extractThumbnails​(java.io.InputStream is, java.lang.String pathToThumbnail) throws java.io.IOException
      Extracts thumbnail images from JFIF/APP0, Exif APP1 and/or Adobe APP13 segment if any.
      Parameters:
      is - InputStream for the JPEG image.
      pathToThumbnail - a path or a path and name prefix combination for the extracted thumbnails.
      Throws:
      java.io.IOException
    • getICCProfile

      public static ICCProfile getICCProfile​(java.io.InputStream is) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertComments

      public static void insertComments​(java.io.InputStream is, java.io.OutputStream os, java.util.List<java.lang.String> comments) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertExif

      public static void insertExif​(java.io.InputStream is, java.io.OutputStream os, Exif exif, boolean update) throws java.io.IOException
      Parameters:
      is - input image stream
      os - output image stream
      exif - Exif instance
      update - True to keep the original data, otherwise false
      Throws:
      java.lang.Exception
      java.io.IOException
    • insertICCProfile

      public static void insertICCProfile​(java.io.InputStream is, java.io.OutputStream os, byte[] data) throws java.io.IOException
      Insert ICC_Profile as one or more APP2 segments
      Parameters:
      is - input stream for the original image
      os - output stream to write the ICC_Profile
      data - ICC_Profile data array to be inserted
      Throws:
      java.io.IOException
    • insertICCProfile

      public static void insertICCProfile​(java.io.InputStream is, java.io.OutputStream os, java.awt.color.ICC_Profile icc_profile) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertICCProfile

      public static void insertICCProfile​(java.io.InputStream is, java.io.OutputStream os, ICCProfile icc_profile) throws java.lang.Exception
      Throws:
      java.lang.Exception
    • insertIPTC

      public static void insertIPTC​(java.io.InputStream is, java.io.OutputStream os, java.util.Collection<IPTCDataSet> iptcs, boolean update) throws java.io.IOException
      Inserts a list of IPTCDataSet into a JPEG APP13 Photoshop IRB segment
      Parameters:
      is - InputStream for the original image
      os - OutputStream for the image with IPTC inserted
      iptcs - a collection of IPTCDataSet to be inserted
      update - boolean if true, keep the original IPTC data; otherwise, replace it completely with the new IPTC data
      Throws:
      java.io.IOException
    • insertIRB

      public static void insertIRB​(java.io.InputStream is, java.io.OutputStream os, java.util.Collection<_8BIM> bims, boolean update) throws java.io.IOException
      Inserts a collection of _8BIM into a JPEG APP13 Photoshop IRB segment
      Parameters:
      is - InputStream for the original image
      os - OutputStream for the image with _8BIMs inserted
      bims - a collection of _8BIM to be inserted
      update - boolean if true, keep the other _8BIMs; otherwise, replace the whole IRB with the inserted _8BIMs
      Throws:
      java.io.IOException
    • insertIRBThumbnail

      public static void insertIRBThumbnail​(java.io.InputStream is, java.io.OutputStream os, java.awt.image.BufferedImage thumbnail) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertXMP

      public static void insertXMP​(java.io.InputStream is, java.io.OutputStream os, XMP xmp) throws java.io.IOException
      Insert a XMP instance into the image. The XMP instance must be able to fit into one APP1.
      Parameters:
      is - InputStream for the image.
      os - OutputStream for the image.
      xmp - XMP instance
      Throws:
      java.io.IOException
    • insertXMP

      public static void insertXMP​(java.io.InputStream is, java.io.OutputStream os, java.lang.String xmp, java.lang.String extendedXmp) throws java.io.IOException
      Insert XMP into single APP1 or multiple segments. Support ExtendedXMP. The standard part of the XMP must be a valid XMP with packet wrapper and, should already include the GUID for the ExtendedXMP in case of ExtendedXMP.

      When converted to bytes, the XMP part should be able to fit into one APP1.

      Parameters:
      is - InputStream for the image.
      os - OutputStream for the image.
      xmp - XML string for the XMP - Assuming in UTF-8 format.
      extendedXmp - XML string for the extended XMP - Assuming in UTF-8 format
      Throws:
      java.io.IOException
    • readMetadata

      public static java.util.Map<MetadataType,​Metadata> readMetadata​(java.io.InputStream is) throws java.io.IOException
      Throws:
      java.io.IOException
    • removeAPPn

      public static void removeAPPn​(Marker APPn, java.io.InputStream is, java.io.OutputStream os) throws java.io.IOException
      Throws:
      java.io.IOException
    • removeMetadata

      public static java.util.Map<MetadataType,​Metadata> removeMetadata​(java.io.InputStream is, java.io.OutputStream os, MetadataType... metadataTypes) throws java.io.IOException
      Removes metadata specified by the input MetadataType set.
      Parameters:
      metadataTypes - a set containing all the MetadataTypes to be removed.
      is - InputStream for the original image.
      os - OutputStream for the image with metadata removed.
      Returns:
      A map of the removed metadata
      Throws:
      java.io.IOException
    • removeMetadata

      public static java.util.Map<MetadataType,​Metadata> removeMetadata​(java.util.Set<MetadataType> metadataTypes, java.io.InputStream is, java.io.OutputStream os) throws java.io.IOException
      Removes metadata specified by the input MetadataType set.
      Parameters:
      metadataTypes - a set containing all the MetadataTypes to be removed.
      is - InputStream for the original image.
      os - OutputStream for the image with metadata removed.
      Returns:
      A map of the removed metadata
      Throws:
      java.io.IOException