Examples of TIFFImageMetadata


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

    }

    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

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

      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

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

      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

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

      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

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

      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

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

            .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

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

      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)
        outputSet =  new TiffOutputSet();
View Full Code Here

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

      printTagValue(jpegMetadata, TiffConstants.GPS_TAG_GPS_LONGITUDE);

      System.out.println();

      // simple interface to GPS data
      TiffImageMetadata exifMetadata = jpegMetadata.getExif();
      if (null != exifMetadata)
      {
        TiffImageMetadata.GPSInfo gpsInfo = exifMetadata.getGPS();
        if (null != gpsInfo)
        {
          String gpsDescription = gpsInfo.toString();
          double longitude = gpsInfo.getLongitudeAsDegreesEast();
          double latitude = gpsInfo.getLatitudeAsDegreesNorth();
View Full Code Here

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

        // TODO: should be an eRewriter to get back the Exif part!

        IImageMetadata metaData = Sanselan.getMetadata(f);
        JpegImageMetadata jMetaData = (JpegImageMetadata) metaData;
        assert (jMetaData != null);
        TiffImageMetadata exif = jMetaData.getExif();
        TiffOutputSet outputSet = exif.getOutputSet();
        TiffOutputField field = outputSet.findField(TiffConstants.EXIF_TAG_PROCESSING_SOFTWARE);
        if (null != field) {
      outputSet.removeField(TiffConstants.EXIF_TAG_PROCESSING_SOFTWARE);
      String fieldString = "Edited by DeExifier. andreas.reichart@gmail.com";
      TiffOutputField newField = new TiffOutputField(ExifTagConstants.EXIF_TAG_PROCESSING_SOFTWARE,
        TiffFieldTypeConstants.FIELD_TYPE_ASCII, fieldString.length(), fieldString.getBytes());
      TiffOutputDirectory outDirectory = outputSet.getOrCreateExifDirectory();
      outDirectory.add(newField);
        }

        eRewriter.updateExifMetadataLossless(imageByte, bOutputStream, outputSet);

    }

    // if (removeExif & removeIptc) {
    // TODO: removeExif & removeIptc
    // }

    // OK, works: recompressed image is already empty.
    if (!removeExif && !removeIptc) {

        IImageMetadata metadata = Sanselan.getMetadata(f);
        JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
        if (jpegMetadata != null) {
      TiffImageMetadata exif = jpegMetadata.getExif();
      if (exif != null) {
          TiffOutputSet outputSet = exif.getOutputSet();
          TiffOutputSet emptySet = new TiffOutputSet();
          new ExifRewriter().removeExifMetadata(imageByte, bOutputStream);
      }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.