Package org.apache.sanselan.formats.tiff

Examples of org.apache.sanselan.formats.tiff.TiffImageMetadata$Directory


        JpegImageMetadata metadata = (JpegImageMetadata) Sanselan
            .getMetadata(imageFile, params);
        if (null == metadata)
          continue;

        TiffImageMetadata exifMetadata = metadata.getExif();
        if (null == exifMetadata)
          continue;

        TiffImageMetadata.GPSInfo gpsInfo = exifMetadata.getGPS();
        if (null == gpsInfo)
          continue;

        Debug.debug("imageFile", imageFile);
        Debug.debug("gpsInfo", gpsInfo);
View Full Code Here


  }

  public IImageMetadata getMetadata(ByteSource byteSource, Map params)
      throws ImageReadException, IOException
  {
    TiffImageMetadata exif = getExifMetadata(byteSource, params);

    JpegPhotoshopMetadata photoshop = getPhotoshopMetadata(byteSource,
        params);

    if (null == exif && null == photoshop)
View Full Code Here

  public Map<String, String> getHeaders(final InputStream inputStream) throws IOException {
    try {
      IImageMetadata metadata = Sanselan.getMetadata(IOUtils.toByteArray(inputStream));
      JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
      if (jpegMetadata != null) {
        TiffImageMetadata exif = jpegMetadata.getExif();
        if (exif != null) {
          Map<String, String> headers = new HashMap<String, String>();
          List<TiffField> fields = exif.getAllFields();

          for (TiffField field : fields) {
            String key = field.getTagName();
            String value = this.getFieldValue(field);
            headers.put(key, value);
View Full Code Here

    }

    public IImageMetadata getMetadata(ByteSource byteSource, Map params)
            throws ImageReadException, IOException
    {
        TiffImageMetadata exif = getExifMetadata(byteSource, params);

        JpegPhotoshopMetadata photoshop = getPhotoshopMetadata(byteSource,
                params);

        if (null == exif && null == photoshop)
View Full Code Here

    }

    public IImageMetadata getMetadata(ByteSource byteSource, Map params)
            throws ImageReadException, IOException
    {
        TiffImageMetadata exif = getExifMetadata(byteSource, params);

        JpegPhotoshopMetadata photoshop = getPhotoshopMetadata(byteSource,
                params);

        if (null == exif && null == photoshop)
View Full Code Here

      JpegImageMetadata originalMetadata = (JpegImageMetadata) Sanselan
          .getMetadata(imageFile);
      assertNotNull(originalMetadata);

      TiffImageMetadata oldExifMetadata = originalMetadata.getExif();
      assertNotNull(oldExifMetadata);

      ByteSource stripped;
      {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        new ExifRewriter().removeExifMetadata(byteSource, baos);
        byte bytes[] = baos.toByteArray();
        File tempFile = createTempFile("removed", ".jpg");
        Debug.debug("tempFile", tempFile);
        IOUtils.writeToFile(bytes, tempFile);

        Debug.debug("Output Segments:");
        stripped = new ByteSourceArray(bytes);
        new JpegUtils().dumpJFIF(stripped);

        assertTrue(!hasExifData(tempFile));
      }

      {
        TiffOutputSet outputSet = oldExifMetadata.getOutputSet();
        //      outputSet.dump();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        new ExifRewriter().updateExifMetadataLossy(stripped, baos,
            outputSet);

        byte bytes[] = baos.toByteArray();
        File tempFile = createTempFile("inserted" + "_", ".jpg");
        Debug.debug("tempFile", tempFile);
        IOUtils.writeToFile(bytes, tempFile);

        Debug.debug("Output Segments:");
        new JpegUtils().dumpJFIF(new ByteSourceArray(bytes));

        //        assertTrue(!hasExifData(tempFile));

        JpegImageMetadata newMetadata = (JpegImageMetadata) Sanselan
            .getMetadata(tempFile);
        assertNotNull(newMetadata);
        TiffImageMetadata newExifMetadata = newMetadata.getExif();
        assertNotNull(newExifMetadata);
        //        newMetadata.dump();

        compare(oldExifMetadata, newExifMetadata);
      }
View Full Code Here

      IImageMetadata metadata = Sanselan.getMetadata(jpegImageFile);
      JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
      if (null != jpegMetadata)
      {
        // note that exif might be null if no Exif metadata is found.
        TiffImageMetadata exif = jpegMetadata.getExif();

        if (null != exif)
        {
          // TiffImageMetadata class is immutable (read-only).
          // TiffOutputSet class represents the Exif data to write.
          //
          // Usually, we want to update existing Exif metadata by
          // changing
          // the values of a few fields, or adding a field.
          // In these cases, it is easiest to use getOutputSet() to
          // start with a "copy" of the fields read from the image.
          outputSet = exif.getOutputSet();
        }
      }

      // if file does not contain any exif metadata, we create an empty
      // set of exif metadata. Otherwise, we keep all of the other
View Full Code Here

      IImageMetadata metadata = Sanselan.getMetadata(jpegImageFile);
      JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
      if (null != jpegMetadata)
      {
        // note that exif might be null if no Exif metadata is found.
        TiffImageMetadata exif = jpegMetadata.getExif();

        if (null != exif)
        {
          // TiffImageMetadata class is immutable (read-only).
          // TiffOutputSet class represents the Exif data to write.
          //
          // Usually, we want to update existing Exif metadata by
          // changing
          // the values of a few fields, or adding a field.
          // In these cases, it is easiest to use getOutputSet() to
          // start with a "copy" of the fields read from the image.
          outputSet = exif.getOutputSet();
        }
      }

      if (null == outputSet)
      {
View Full Code Here

      IImageMetadata metadata = Sanselan.getMetadata(jpegImageFile);
      JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
      if (null != jpegMetadata)
      {
        // note that exif might be null if no Exif metadata is found.
        TiffImageMetadata exif = jpegMetadata.getExif();

        if (null != exif)
        {
          // TiffImageMetadata class is immutable (read-only).
          // TiffOutputSet class represents the Exif data to write.
          //
          // Usually, we want to update existing Exif metadata by
          // changing
          // the values of a few fields, or adding a field.
          // In these cases, it is easiest to use getOutputSet() to
          // start with a "copy" of the fields read from the image.
          outputSet = exif.getOutputSet();
        }
      }

      // if file does not contain any exif metadata, we create an empty
      // set of exif metadata. Otherwise, we keep all of the other
View Full Code Here

            .getMetadata(imageFile);
        if (null == oldMetadata)
          continue;
        assertNotNull(oldMetadata);

        TiffImageMetadata oldExifMetadata = oldMetadata.getExif();
        if (null == oldExifMetadata)
          continue;
        assertNotNull(oldExifMetadata);
        oldMetadata.dump();

        //      TiffImageMetadata tiffImageMetadata = metadata.getExif();
        //      Photoshop photoshop = metadata.getPhotoshop();

        TiffOutputSet outputSet = oldExifMetadata.getOutputSet();
        //      outputSet.dump();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        rewriter.rewrite(byteSource, baos, outputSet);
        byte bytes[] = baos.toByteArray();
        File tempFile = createTempFile(name + "_", ".jpg");
        Debug.debug("tempFile", tempFile);
        IOUtils.writeToFile(bytes, tempFile);

        Debug.debug("Output Segments:");
        new JpegUtils().dumpJFIF(new ByteSourceArray(bytes));

        //        assertTrue(!hasExifData(tempFile));

        JpegImageMetadata newMetadata = (JpegImageMetadata) Sanselan
            .getMetadata(tempFile);
        assertNotNull(newMetadata);
        TiffImageMetadata newExifMetadata = newMetadata.getExif();
        assertNotNull(newExifMetadata);
        //        newMetadata.dump();

        compare(oldExifMetadata, newExifMetadata);
      }
View Full Code Here

TOP

Related Classes of org.apache.sanselan.formats.tiff.TiffImageMetadata$Directory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.