Package org.apache.sanselan.formats.tiff

Examples of org.apache.sanselan.formats.tiff.TiffField$OversizeValueElement


  public String getData(int field) throws NoMetaDataException {
    logger.log(Level.FINEST, "get data " + field + " from "
        + file.getPath());

    String value = null;
    TiffField valueField;

    if (jpegMetadata != null && jpegMetadata.getExif() != null) {
      switch (field) {
      case InfoConstants.GPS_LATITUDE:
        try {
          if (jpegMetadata.getExif() != null
              && jpegMetadata.getExif().getGPS() != null) {
            value = String.valueOf(jpegMetadata.getExif().getGPS()
                .getLatitudeAsDegreesNorth());
            if (jpegMetadata.getExif().getGPS().latitudeRef == GPSTagConstants.GPS_TAG_GPS_DEST_LATITUDE_REF_VALUE_SOUTH) {
              value = "-" + value;
            }
          } else {
            logger.log(Level.FINER,
                "no meta data for latitude exist in "
                    + getFile().getPath());
            throw new NoMetaDataException(
                "no meta data for latitude exist in "
                    + getFile().getPath());
          }
        } catch (ImageReadException ire) {
          logger.log(Level.WARNING,
              "error while reading latitude from "
                  + file.getName(), ire);
        }
        break;
      case InfoConstants.GPS_LONGITUDE:
        try {
          if (jpegMetadata.getExif() != null
              && jpegMetadata.getExif().getGPS() != null) {
            value = String.valueOf(jpegMetadata.getExif().getGPS()
                .getLongitudeAsDegreesEast());
            if (jpegMetadata.getExif().getGPS().longitudeRef == GPSTagConstants.GPS_TAG_GPS_DEST_LONGITUDE_REF_VALUE_WEST) {
              value = "-" + value;
            }
          } else {
            logger.log(Level.FINER,
                "no meta data for longitude exist in "
                    + getFile().getPath());
            throw new NoMetaDataException(
                "no meta data for longitude exist in "
                    + getFile().getPath());
          }
        } catch (ImageReadException ire) {
          logger.log(Level.WARNING,
              "error while reading longitude from "
                  + file.getName(), ire);
        }
        break;
      case InfoConstants.DATE_TIME:
        /* format 'yyyy:MM:dd kk:mm:ss' */
        valueField = jpegMetadata
            .findEXIFValue(TiffConstants.EXIF_TAG_CREATE_DATE);
        if (valueField != null) {
          value = valueField.getValueDescription();
          value = value.substring(1, value.length() - 1);
        }
        break;
      case InfoConstants.USER_COMMENT:
        valueField = jpegMetadata
            .findEXIFValue(TiffConstants.EXIF_TAG_USER_COMMENT);
        if (valueField != null) {
          value = valueField.getValueDescription();
          value = value.substring(1, value.length() - 1);
        }
        break;
      case InfoConstants.IMAGE_DESCRIPTION:
        valueField = jpegMetadata
            .findEXIFValue(TiffConstants.TIFF_TAG_IMAGE_DESCRIPTION);
        if (valueField != null) {
          value = valueField.getValueDescription();
          value = value.substring(1, value.length() - 1);
        }
        break;
      }
    } else {
View Full Code Here


          System.out.println("  " + "GPS Latitude (Degrees North): " + latitude);
        }
      }

      // more specific example of how to manually access GPS values
      TiffField gpsLatitudeRefField = jpegMetadata
          .findEXIFValue(TiffConstants.GPS_TAG_GPS_LATITUDE_REF);
      TiffField gpsLatitudeField = jpegMetadata
          .findEXIFValue(TiffConstants.GPS_TAG_GPS_LATITUDE);
      TiffField gpsLongitudeRefField = jpegMetadata
          .findEXIFValue(TiffConstants.GPS_TAG_GPS_LONGITUDE_REF);
      TiffField gpsLongitudeField = jpegMetadata
          .findEXIFValue(TiffConstants.GPS_TAG_GPS_LONGITUDE);
      if (gpsLatitudeRefField != null && gpsLatitudeField != null
          && gpsLongitudeRefField != null
          && gpsLongitudeField != null)
      {
        // all of these values are strings.
        String gpsLatitudeRef = (String) gpsLatitudeRefField.getValue();
        RationalNumber gpsLatitude[] = (RationalNumber[]) (gpsLatitudeField
            .getValue());
        String gpsLongitudeRef = (String) gpsLongitudeRefField
            .getValue();
        RationalNumber gpsLongitude[] = (RationalNumber[]) gpsLongitudeField
            .getValue();

        RationalNumber gpsLatitudeDegrees = gpsLatitude[0];
        RationalNumber gpsLatitudeMinutes = gpsLatitude[1];
        RationalNumber gpsLatitudeSeconds = gpsLatitude[2];
View Full Code Here

  }

  private static void printTagValue(JpegImageMetadata jpegMetadata,
      TagInfo tagInfo) throws ImageReadException, IOException
  {
    TiffField field = jpegMetadata.findEXIFValue(tagInfo);
    if (field == null)
      System.out.println(tagInfo.name + ": " + "Not Found.");
    else
      System.out.println(tagInfo.name + ": "
          + field.getValueDescription());
  }
View Full Code Here

          byteSource, params);

      if (metadata != null)
      {
        {
          TiffField field = metadata
              .findEXIFValue(TIFF_TAG_XRESOLUTION);
          if (field != null)
            x_density = ((Number) field.getValue()).doubleValue();
        }
        {
          TiffField field = metadata
              .findEXIFValue(TIFF_TAG_YRESOLUTION);
          if (field != null)
            y_density = ((Number) field.getValue()).doubleValue();
        }
        {
          TiffField field = metadata
              .findEXIFValue(TIFF_TAG_RESOLUTION_UNIT);
          if (field != null)
          {
            int density_units = ((Number) field.getValue())
                .intValue();

            switch (density_units)
            {
              case 1 :
View Full Code Here

      Object o = items.get(i);
      if (!(o instanceof TiffImageMetadata.Item))
        continue;

      TiffImageMetadata.Item item = (TiffImageMetadata.Item) o;
      TiffField field = item.getTiffField();
      if (field.tag == tagInfo.tag)
        return field;
    }

    return null;
View Full Code Here

      return;

    List fields = exif.getAllFields();
    for (int i = 0; i < fields.size(); i++)
    {
      TiffField field = (TiffField) fields.get(i);
      checkField(imageFile, field);
    }

  }
View Full Code Here

  {
    Hashtable fieldMap = new Hashtable();
    for (int i = 0; i < items.size(); i++)
    {
      TiffImageMetadata.Item item = (TiffImageMetadata.Item) items.get(i);
      TiffField field = item.getTiffField();
      Object key = new Integer(field.tag);
      if (!fieldMap.containsKey(key))
        fieldMap.put(key, field);
    }
    return fieldMap;
View Full Code Here

      for (int j = 0; j < oldFieldTags.size(); j++)
      {
        Integer fieldTag = (Integer) oldFieldTags.get(j);

        TiffField oldField = (TiffField) oldFieldMap.get(fieldTag);
        TiffField newField = (TiffField) newFieldMap.get(fieldTag);

        //        Debug.debug("fieldTag", fieldTag);
        //        Debug.debug("oldField", oldField);
        //        Debug.debug("newField", newField);

        //        fieldTag.
        assertNotNull(oldField);
        assertNotNull(newField);

        assertEquals(oldField.tag, newField.tag);
        assertEquals(dirType.intValue(), newField.directoryType);
        assertEquals(oldField.directoryType, newField.directoryType);
        assertEquals(oldField.length, newField.length);
        assertEquals(oldField.isLocalValue(), newField.isLocalValue());

        if (oldField.tag == 0x202)
        {
          // ignore "jpg from raw length" value. may have off-by-one bug in certain cameras.
          // i.e. Sony DCR-PC110
          continue;
        }

        if (!oldField.tagInfo.isOffset())
        {
          if (oldField.tagInfo.isText())
            ;
          else if (oldField.isLocalValue())
          {
            //            Debug.debug("oldField.tag", oldField.tag);
            //            Debug.debug("newField.tag", newField.tag);
            //            Debug.debug("oldField.tagInfo", oldField.tagInfo);
            //            Debug.debug("newField.tagInfo", newField.tagInfo);
            //            Debug.debug("oldField.fieldType", oldField.fieldType);
            //            Debug.debug("newField.fieldType", newField.fieldType);
            //            Debug.debug("oldField.getBytesLength", oldField
            //                .getBytesLength());
            //            Debug.debug("newField.getBytesLength", newField
            //                .getBytesLength());
            //
            //            Debug.debug("oldField.valueOffsetBytes",
            //                oldField.valueOffsetBytes);
            //            Debug.debug("newField.valueOffsetBytes",
            //                newField.valueOffsetBytes);

            if (oldField.tag == 0x116 || oldField.tag == 0x117)
              compare(oldField, newField);
            else
              compare(oldField.valueOffsetBytes,
                  newField.valueOffsetBytes, oldField
                      .getBytesLength(), newField
                      .getBytesLength());
          }
          else
          {
            //            Debug.debug("oldField.tagInfo", oldField.tagInfo);
View Full Code Here

          byteSource, params);

      if (metadata != null)
      {
        {
          TiffField field = metadata
              .findEXIFValue(TIFF_TAG_XRESOLUTION);
          if (field != null)
            x_density = ((Number) field.getValue()).doubleValue();
        }
        {
          TiffField field = metadata
              .findEXIFValue(TIFF_TAG_YRESOLUTION);
          if (field != null)
            y_density = ((Number) field.getValue()).doubleValue();
        }
        {
          TiffField field = metadata
              .findEXIFValue(TIFF_TAG_RESOLUTION_UNIT);
          if (field != null)
          {
            int density_units = ((Number) field.getValue())
                .intValue();

            switch (density_units)
            {
            case 1:
View Full Code Here

        elements.add(directory);

        List fields = directory.getDirectoryEntrys();
        for (int f = 0; f < fields.size(); f++)
        {
          TiffField field = (TiffField) fields.get(f);
          TiffElement oversizeValue = field.getOversizeValueElement();
          if (oversizeValue != null)
            elements.add(oversizeValue);

        }
View Full Code Here

TOP

Related Classes of org.apache.sanselan.formats.tiff.TiffField$OversizeValueElement

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.