Class ExifRewriter

    • Constructor Detail

      • ExifRewriter

        public ExifRewriter()
        Constructor. to guess whether a file contains an image based on its file extension.
      • ExifRewriter

        public ExifRewriter​(ByteOrder byteOrder)
        Constructor.

        Parameters:
        byteOrder - byte order of EXIF segment.
    • Method Detail

      • updateExifMetadataLossless

        public void updateExifMetadataLossless​(File src,
                                               OutputStream os,
                                               TiffOutputSet outputSet)
                                        throws ImageReadException,
                                               IOException,
                                               ImageWriteException
        Reads a Jpeg image, replaces the EXIF metadata and writes the result to a stream.

        Note that this uses the "Lossless" approach - in order to preserve data embedded in the EXIF segment that it can't parse (such as Maker Notes), this algorithm avoids overwriting any part of the original segment that it couldn't parse. This can cause the EXIF segment to grow with each update, which is a serious issue, since all EXIF data must fit in a single APP1 segment of the Jpeg image.

        Parameters:
        src - Image file.
        os - OutputStream to write the image to.
        outputSet - TiffOutputSet containing the EXIF data to write.
        Throws:
        ImageReadException - if it fails to read the JFIF segments
        IOException - if it fails to read the image data
        ImageWriteException - if it fails to write the updated data
      • updateExifMetadataLossless

        public void updateExifMetadataLossless​(byte[] src,
                                               OutputStream os,
                                               TiffOutputSet outputSet)
                                        throws ImageReadException,
                                               IOException,
                                               ImageWriteException
        Reads a Jpeg image, replaces the EXIF metadata and writes the result to a stream.

        Note that this uses the "Lossless" approach - in order to preserve data embedded in the EXIF segment that it can't parse (such as Maker Notes), this algorithm avoids overwriting any part of the original segment that it couldn't parse. This can cause the EXIF segment to grow with each update, which is a serious issue, since all EXIF data must fit in a single APP1 segment of the Jpeg image.

        Parameters:
        src - Byte array containing Jpeg image data.
        os - OutputStream to write the image to.
        outputSet - TiffOutputSet containing the EXIF data to write.
        Throws:
        ImageReadException - if it fails to read the JFIF segments
        IOException - if it fails to read the image data
        ImageWriteException - if it fails to write the updated data
      • updateExifMetadataLossless

        public void updateExifMetadataLossless​(InputStream src,
                                               OutputStream os,
                                               TiffOutputSet outputSet)
                                        throws ImageReadException,
                                               IOException,
                                               ImageWriteException
        Reads a Jpeg image, replaces the EXIF metadata and writes the result to a stream.

        Note that this uses the "Lossless" approach - in order to preserve data embedded in the EXIF segment that it can't parse (such as Maker Notes), this algorithm avoids overwriting any part of the original segment that it couldn't parse. This can cause the EXIF segment to grow with each update, which is a serious issue, since all EXIF data must fit in a single APP1 segment of the Jpeg image.

        Parameters:
        src - InputStream containing Jpeg image data.
        os - OutputStream to write the image to.
        outputSet - TiffOutputSet containing the EXIF data to write.
        Throws:
        ImageReadException - if it fails to read the JFIF segments
        IOException - if it fails to read the image data
        ImageWriteException - if it fails to write the updated data
      • updateExifMetadataLossless

        public void updateExifMetadataLossless​(ByteSource byteSource,
                                               OutputStream os,
                                               TiffOutputSet outputSet)
                                        throws ImageReadException,
                                               IOException,
                                               ImageWriteException
        Reads a Jpeg image, replaces the EXIF metadata and writes the result to a stream.

        Note that this uses the "Lossless" approach - in order to preserve data embedded in the EXIF segment that it can't parse (such as Maker Notes), this algorithm avoids overwriting any part of the original segment that it couldn't parse. This can cause the EXIF segment to grow with each update, which is a serious issue, since all EXIF data must fit in a single APP1 segment of the Jpeg image.

        Parameters:
        byteSource - ByteSource containing Jpeg image data.
        os - OutputStream to write the image to.
        outputSet - TiffOutputSet containing the EXIF data to write.
        Throws:
        ImageReadException - if it fails to read the JFIF segments
        IOException - if it fails to read the image data
        ImageWriteException - if it fails to write the updated data
      • updateExifMetadataLossy

        public void updateExifMetadataLossy​(byte[] src,
                                            OutputStream os,
                                            TiffOutputSet outputSet)
                                     throws ImageReadException,
                                            IOException,
                                            ImageWriteException
        Reads a Jpeg image, replaces the EXIF metadata and writes the result to a stream.

        Note that this uses the "Lossy" approach - the algorithm overwrites the entire EXIF segment, ignoring the possibility that it may be discarding data it couldn't parse (such as Maker Notes).

        Parameters:
        src - Byte array containing Jpeg image data.
        os - OutputStream to write the image to.
        outputSet - TiffOutputSet containing the EXIF data to write.
        Throws:
        ImageReadException - if it fails to read the JFIF segments
        IOException - if it fails to read the image data
        ImageWriteException - if it fails to write the updated data
      • updateExifMetadataLossy

        public void updateExifMetadataLossy​(InputStream src,
                                            OutputStream os,
                                            TiffOutputSet outputSet)
                                     throws ImageReadException,
                                            IOException,
                                            ImageWriteException
        Reads a Jpeg image, replaces the EXIF metadata and writes the result to a stream.

        Note that this uses the "Lossy" approach - the algorithm overwrites the entire EXIF segment, ignoring the possibility that it may be discarding data it couldn't parse (such as Maker Notes).

        Parameters:
        src - InputStream containing Jpeg image data.
        os - OutputStream to write the image to.
        outputSet - TiffOutputSet containing the EXIF data to write.
        Throws:
        ImageReadException - if it fails to read the JFIF segments
        IOException - if it fails to read the image data
        ImageWriteException - if it fails to write the updated data
      • updateExifMetadataLossy

        public void updateExifMetadataLossy​(File src,
                                            OutputStream os,
                                            TiffOutputSet outputSet)
                                     throws ImageReadException,
                                            IOException,
                                            ImageWriteException
        Reads a Jpeg image, replaces the EXIF metadata and writes the result to a stream.

        Note that this uses the "Lossy" approach - the algorithm overwrites the entire EXIF segment, ignoring the possibility that it may be discarding data it couldn't parse (such as Maker Notes).

        Parameters:
        src - Image file.
        os - OutputStream to write the image to.
        outputSet - TiffOutputSet containing the EXIF data to write.
        Throws:
        ImageReadException - if it fails to read the JFIF segments
        IOException - if it fails to read the image data
        ImageWriteException - if it fails to write the updated data
      • updateExifMetadataLossy

        public void updateExifMetadataLossy​(ByteSource byteSource,
                                            OutputStream os,
                                            TiffOutputSet outputSet)
                                     throws ImageReadException,
                                            IOException,
                                            ImageWriteException
        Reads a Jpeg image, replaces the EXIF metadata and writes the result to a stream.

        Note that this uses the "Lossy" approach - the algorithm overwrites the entire EXIF segment, ignoring the possibility that it may be discarding data it couldn't parse (such as Maker Notes).

        Parameters:
        byteSource - ByteSource containing Jpeg image data.
        os - OutputStream to write the image to.
        outputSet - TiffOutputSet containing the EXIF data to write.
        Throws:
        ImageReadException - if it fails to read the JFIF segments
        IOException - if it fails to read the image data
        ImageWriteException - if it fails to write the updated data