Examples of JpegImageMetadata


Examples of org.apache.sanselan.formats.jpeg.JpegImageMetadata

        ByteSource byteSource = new ByteSourceFile(imageFile);
        Debug.debug("Source Segments:");
        new JpegUtils().dumpJFIF(byteSource);

        JpegImageMetadata oldMetadata = (JpegImageMetadata) Sanselan
            .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 = File.createTempFile(name + "_", ".jpg");
        Debug.debug("tempFile", tempFile);
        //      tempFile.deleteOnExit();
        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.jpeg.JpegImageMetadata

        Map params = new HashMap();
        boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
        params.put(PARAM_KEY_READ_THUMBNAILS, new Boolean(
            !ignoreImageData));

        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)
View Full Code Here

Examples of org.apache.sanselan.formats.jpeg.JpegImageMetadata

      boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
      params
          .put(PARAM_KEY_READ_THUMBNAILS, new Boolean(
              !ignoreImageData));

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

      metadata.dump();
    }
  }
View Full Code Here

Examples of org.apache.sanselan.formats.jpeg.JpegImageMetadata

  @Override
  @SuppressWarnings("unchecked")
  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) {
View Full Code Here

Examples of org.apache.sanselan.formats.jpeg.JpegImageMetadata

          if (formatName.startsWith("JPEG")) {
            codecV = "jpg";
            IImageMetadata meta = Sanselan.getMetadata(file);

            if (meta != null && meta instanceof JpegImageMetadata) {
              JpegImageMetadata jpegmeta = (JpegImageMetadata) meta;
              TiffField tf = jpegmeta.findEXIFValue(TiffConstants.EXIF_TAG_MODEL);

              if (tf != null) {
                model = tf.getStringValue().trim();
              }

              tf = jpegmeta.findEXIFValue(TiffConstants.EXIF_TAG_EXPOSURE_TIME);
              if (tf != null) {
                exposure = (int) (1000 * tf.getDoubleValue());
              }

              tf = jpegmeta.findEXIFValue(TiffConstants.EXIF_TAG_ORIENTATION);
              if (tf != null) {
                orientation = tf.getIntValue();
              }

              tf = jpegmeta.findEXIFValue(TiffConstants.EXIF_TAG_ISO);
              if (tf != null) {
                // Galaxy Nexus jpg pictures may contain multiple values, take the first
                int[] isoValues = tf.getIntArrayValue();
                iso = isoValues[0];
              }
View Full Code Here

Examples of org.apache.sanselan.formats.jpeg.JpegImageMetadata

      params
          .put(PARAM_KEY_READ_THUMBNAILS, new Boolean(
              !ignoreImageData));
      // params.put(PARAM_KEY_VERBOSE, Boolean.TRUE);

      JpegImageMetadata metadata = (JpegImageMetadata) Sanselan
          .getMetadata(imageFile, params);
      assertNotNull(metadata);
      assertNotNull(metadata.getPhotoshop());

      metadata.getPhotoshop().dump();
      // if(metadata.getPhotoshop().getItems().size()>0)
      // Debug.debug("iptc size",
      // metadata.getPhotoshop().getItems().size());

      JpegPhotoshopMetadata psMetadata = metadata.getPhotoshop();
      List oldRecords = psMetadata.photoshopApp13Data.getRecords();

      System.out.println();
      for (int j = 0; j < oldRecords.size(); j++)
      {
View Full Code Here

Examples of org.apache.sanselan.formats.jpeg.JpegImageMetadata

      ByteSource byteSource = new ByteSourceFile(imageFile);
      Debug.debug("Source Segments:");
      new JpegUtils().dumpJFIF(byteSource);

      {
        JpegImageMetadata metadata = (JpegImageMetadata) Sanselan
            .getMetadata(imageFile);
        //        assertNotNull(metadata.getExif());
      }

      {
View Full Code Here

Examples of org.apache.sanselan.formats.jpeg.JpegImageMetadata

      ByteSource byteSource = new ByteSourceFile(imageFile);
      Debug.debug("Source Segments:");
      new JpegUtils().dumpJFIF(byteSource);

      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.jpeg.JpegImageMetadata

        ByteSource byteSource = new ByteSourceFile(imageFile);
        Debug.debug("Source Segments:");
        new JpegUtils().dumpJFIF(byteSource);

        JpegImageMetadata oldMetadata = (JpegImageMetadata) Sanselan
            .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.jpeg.JpegImageMetadata

    {
      TiffOutputSet outputSet = null;

      // note that metadata might be null if no metadata is found.
      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.
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.