Package org.apache.sanselan.formats.tiff.write

Examples of org.apache.sanselan.formats.tiff.write.TiffOutputDirectory


                // This is a bug.
                // Ignore second directory of a given type.
                continue;
            }

            TiffOutputDirectory outputDirectory = srcDir
                    .getOutputDirectory(byteOrder);
            result.addDirectory(outputDirectory);
        }

        return result;
View Full Code Here


        public TiffOutputDirectory getOutputDirectory(int byteOrder)
                throws ImageWriteException
        {
            try
            {
                TiffOutputDirectory dstDir = new TiffOutputDirectory(type);

                ArrayList entries = getItems();
                for (int i = 0; i < entries.size(); i++)
                {
                    TiffImageMetadata.Item item = (TiffImageMetadata.Item) entries
                            .get(i);
                    TiffField srcField = item.getTiffField();

                    if (null != dstDir.findField(srcField.tag))
                    {
                        // ignore duplicate tags in a directory.
                        continue;
                    }
                    else if (srcField.tagInfo instanceof TagInfo.Offset)
                    {
                        // ignore offset fields.
                        continue;
                    }

                    TagInfo tagInfo = srcField.tagInfo;
                    FieldType fieldType = srcField.fieldType;
                    int count = srcField.length;
                    //            byte bytes[] = srcField.fieldType.getRawBytes(srcField);

                    //                    Debug.debug("tagInfo", tagInfo);

                    Object value = srcField.getValue();

                    //                    Debug.debug("value", Debug.getType(value));

                    byte bytes[] = tagInfo.encodeValue(fieldType, value,
                            byteOrder);

                    //                    if (tagInfo.isUnknown())
                    //                        Debug.debug(
                    //                                "\t" + "unknown tag(0x"
                    //                                        + Integer.toHexString(srcField.tag)
                    //                                        + ") bytes", bytes);

                    TiffOutputField dstField = new TiffOutputField(
                            srcField.tag, tagInfo, fieldType, count, bytes);
                    dstField.setSortHint(srcField.getSortHint());
                    dstDir.add(dstField);
                }

                dstDir.setTiffImageData(getTiffImageData());
                dstDir.setJpegImageData(getJpegImageData());

                return dstDir;
            }
            catch (ImageReadException e)
            {
View Full Code Here

        // org.apache.sanselan.formats.tiff.constants.AllTagConstants
        //
        TiffOutputField aperture = TiffOutputField.create(
            TiffConstants.EXIF_TAG_APERTURE_VALUE,
            outputSet.byteOrder, new Double(0.3));
        TiffOutputDirectory exifDirectory = outputSet
            .getOrCreateExifDirectory();
        // make sure to remove old value if present (this method will
        // not fail if the tag does not exist).
        exifDirectory
            .removeField(TiffConstants.EXIF_TAG_APERTURE_VALUE);
        exifDirectory.add(aperture);
      }

      {
        // Example of how to add/update GPS info to output set.
View Full Code Here

        // One complicating factor is that in some cases, manufacturers
        // will place the same tag in different directories.
        // To learn which directory a tag appears in, either refer to
        // the constants in ExifTagConstants.java or go to Phil Harvey's
        // EXIF website.
        TiffOutputDirectory exifDirectory = outputSet
            .getExifDirectory();
        if (null != exifDirectory)
          exifDirectory
              .removeField(TiffConstants.EXIF_TAG_APERTURE_VALUE);
      }

      os = new FileOutputStream(dst);
      os = new BufferedOutputStream(os);
View Full Code Here

        // see org.apache.sanselan.formats.tiff.constants.AllTagConstants
        //
        TiffOutputField aperture = TiffOutputField.create(
            TiffConstants.EXIF_TAG_APERTURE_VALUE,
            outputSet.byteOrder, new Double(0.3));
        TiffOutputDirectory exifDirectory = outputSet
            .getOrCreateExifDirectory();
        exifDirectory.add(aperture);
      }

      {
        // Example of how to add/update GPS info to output set.
View Full Code Here

        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);

    }
View Full Code Here

TOP

Related Classes of org.apache.sanselan.formats.tiff.write.TiffOutputDirectory

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.