Package org.apache.sanselan.common.byteSources

Examples of org.apache.sanselan.common.byteSources.ByteSource


      File imageFile = (File) images.get(i);
//       Debug.debug("imageFile", imageFile);
//       Debug.debug();

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

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

      JpegPhotoshopMetadata metadata = new JpegImageParser()
          .getPhotoshopMetadata(byteSource, params);
      // metadata.dump();

      {
        List newBlocks = new ArrayList();
        List newRecords = new ArrayList();

        if (null != metadata)
        {
          boolean keepOldIptcNonTextValues = true;
          if (keepOldIptcNonTextValues)
            newBlocks.addAll(metadata.photoshopApp13Data
                .getNonIptcBlocks());
          boolean keepOldIptcTextValues = true;
          if (keepOldIptcTextValues)
          {
            List oldRecords = metadata.photoshopApp13Data
                .getRecords();

            newRecords = new ArrayList();
            for (int j = 0; j < oldRecords.size(); j++)
            {
              IPTCRecord record = (IPTCRecord) oldRecords.get(j);
              if (record.iptcType.type != IPTCConstants.IPTC_TYPE_CITY.type
                  && record.iptcType.type != IPTCConstants.IPTC_TYPE_CREDIT.type)
                newRecords.add(record);
            }
          }
        }

        newRecords.add(new IPTCRecord(IPTCConstants.IPTC_TYPE_CITY,
            "Albany, NY"));
        newRecords.add(new IPTCRecord(IPTCConstants.IPTC_TYPE_CREDIT,
            "William Sorensen"));

        PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords,
            newBlocks);

        File updated = createTempFile(imageFile.getName()
            + ".iptc.add.", ".jpg");
        OutputStream os = null;
        try
        {
          os = new FileOutputStream(updated);
          os = new BufferedOutputStream(os);
          new JpegIptcRewriter().writeIPTC(byteSource, os, newData);
        } finally
        {
          os.close();
          os = null;
        }

        // Debug.debug("Destination Segments:");
        // new JpegUtils().dumpJFIF(new ByteSourceFile(updated));

        ByteSource updateByteSource = new ByteSourceFile(updated);
        JpegPhotoshopMetadata outMetadata = new JpegImageParser()
            .getPhotoshopMetadata(updateByteSource, params);

        // Debug.debug("outMetadata", outMetadata.toString());
        // Debug.debug("hasIptcSegment", new JpegImageParser()
View Full Code Here


    //if (format != ImageFormat.IMAGE_FORMAT_JPEG)
    //  return false;

    try
    {
      ByteSource byteSource = new ByteSourceFile(file);
      return new JpegImageParser().hasIptcSegment(byteSource);
    }
    catch (Exception e)
    {
      //      Debug.debug("Error file", file.getAbsoluteFile());
View Full Code Here

TOP

Related Classes of org.apache.sanselan.common.byteSources.ByteSource

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.