Package pixy.meta

Class Metadata

java.lang.Object
pixy.meta.Metadata
All Implemented Interfaces:
java.lang.Iterable<MetadataEntry>, MetadataReader, Reader
Direct Known Subclasses:
Adobe, Comments, DDB, Ducky, Exif, ICCProfile, ImageMetadata, IPTC, IRB, JFIF, TextualChunks, TIMEChunk, XMP

public abstract class Metadata
extends java.lang.Object
implements MetadataReader, java.lang.Iterable<MetadataEntry>
Base class for image metadata.
Version:
1.0 01/12/2015
Author:
Wen Yu, yuwen_66@yahoo.com
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected byte[] data  
    static int IMAGE_MAGIC_NUMBER_LEN  
    protected boolean isDataRead  
  • Constructor Summary

    Constructors 
    Constructor Description
    Metadata​(MetadataType type)  
    Metadata​(MetadataType type, byte[] data)  
  • Method Summary

    Modifier and Type Method Description
    void ensureDataRead()  
    static void extractThumbnails​(java.io.File image, java.lang.String pathToThumbnail)  
    static void extractThumbnails​(java.io.InputStream is, java.lang.String pathToThumbnail)  
    static void extractThumbnails​(java.lang.String image, java.lang.String pathToThumbnail)  
    byte[] getData()  
    MetadataType getType()  
    static void insertComment​(java.io.InputStream is, java.io.OutputStream os, java.lang.String comment)  
    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)  
    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 out, byte[] icc_profile)  
    static void insertIPTC​(java.io.InputStream is, java.io.OutputStream out, java.util.Collection<IPTCDataSet> iptcs)  
    static void insertIPTC​(java.io.InputStream is, java.io.OutputStream out, java.util.Collection<IPTCDataSet> iptcs, boolean update)  
    static void insertIRB​(java.io.InputStream is, java.io.OutputStream out, java.util.Collection<_8BIM> bims)  
    static void insertIRB​(java.io.InputStream is, java.io.OutputStream out, java.util.Collection<_8BIM> bims, boolean update)  
    static void insertIRBThumbnail​(java.io.InputStream is, java.io.OutputStream out, java.awt.image.BufferedImage thumbnail)  
    static void insertXMP​(java.io.InputStream is, java.io.OutputStream out, java.lang.String xmp)  
    static void insertXMP​(java.io.InputStream is, java.io.OutputStream out, XMP xmp)  
    boolean isDataRead()  
    static java.util.Map<MetadataType,​Metadata> readMetadata​(java.io.File image)  
    static java.util.Map<MetadataType,​Metadata> readMetadata​(java.io.InputStream is)
    Reads all metadata associated with the input image
    static java.util.Map<MetadataType,​Metadata> readMetadata​(java.lang.String image)  
    static java.util.Map<MetadataType,​Metadata> removeMetadata​(java.io.InputStream is, java.io.OutputStream os, MetadataType... metadataTypes)
    Remove meta data from image
    void write​(java.io.OutputStream out)
    Writes the metadata out to the output stream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator

    Methods inherited from interface pixy.util.Reader

    read
  • Field Details

  • Constructor Details

  • Method Details

    • extractThumbnails

      public static void extractThumbnails​(java.io.File image, java.lang.String pathToThumbnail) 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
      Throws:
      java.io.IOException
    • extractThumbnails

      public static void extractThumbnails​(java.lang.String image, java.lang.String pathToThumbnail) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertComment

      public static void insertComment​(java.io.InputStream is, java.io.OutputStream os, java.lang.String comment) 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) throws java.io.IOException
      Parameters:
      is - input image stream
      os - output image stream
      exif - Exif instance
      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.io.IOException
    • insertICCProfile

      public static void insertICCProfile​(java.io.InputStream is, java.io.OutputStream out, byte[] icc_profile) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertIPTC

      public static void insertIPTC​(java.io.InputStream is, java.io.OutputStream out, java.util.Collection<IPTCDataSet> iptcs) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertIPTC

      public static void insertIPTC​(java.io.InputStream is, java.io.OutputStream out, java.util.Collection<IPTCDataSet> iptcs, boolean update) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertIRB

      public static void insertIRB​(java.io.InputStream is, java.io.OutputStream out, java.util.Collection<_8BIM> bims) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertIRB

      public static void insertIRB​(java.io.InputStream is, java.io.OutputStream out, java.util.Collection<_8BIM> bims, boolean update) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertIRBThumbnail

      public static void insertIRBThumbnail​(java.io.InputStream is, java.io.OutputStream out, 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 out, XMP xmp) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertXMP

      public static void insertXMP​(java.io.InputStream is, java.io.OutputStream out, java.lang.String xmp) throws java.io.IOException
      Throws:
      java.io.IOException
    • readMetadata

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

      public static java.util.Map<MetadataType,​Metadata> readMetadata​(java.io.InputStream is) throws java.io.IOException
      Reads all metadata associated with the input image
      Parameters:
      is - InputStream for the image
      Returns:
      a list of Metadata for the input stream
      Throws:
      java.io.IOException
    • readMetadata

      public static java.util.Map<MetadataType,​Metadata> readMetadata​(java.lang.String image) 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
      Remove meta data from image
      Parameters:
      is - InputStream for the input image
      os - OutputStream for the output image
      Throws:
      java.io.IOException
    • ensureDataRead

      public void ensureDataRead()
      Specified by:
      ensureDataRead in interface MetadataReader
    • getData

      public byte[] getData()
    • getType

      public MetadataType getType()
      Specified by:
      getType in interface MetadataReader
    • isDataRead

      public boolean isDataRead()
      Specified by:
      isDataRead in interface MetadataReader
    • write

      public void write​(java.io.OutputStream out) throws java.io.IOException
      Writes the metadata out to the output stream
      Parameters:
      out - OutputStream to write the metadata to
      Throws:
      java.io.IOException