Package org.apache.sanselan.common.byteSources

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


    private void dumpElements(List elements) throws IOException
    {
        //        try
        //        {
        ByteSource byteSource = new ByteSourceArray(exifBytes);

        dumpElements(byteSource, elements);
        //        }
        //        catch (ImageReadException e)
        //        {
View Full Code Here


    private List analyzeOldTiff() throws ImageWriteException, IOException
    {
        try
        {
            ByteSource byteSource = new ByteSourceArray(exifBytes);
            Map params = null;
            FormatCompliance formatCompliance = FormatCompliance.getDefault();
            TiffContents contents = new TiffReader(false).readContents(byteSource,
                    params, formatCompliance);
View Full Code Here

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

      ByteSource byteSource = new ByteSourceFile(imageFile);
      Map params = new HashMap();
      String xmpXml = new JpegImageParser().getXmpXml(byteSource, params );
      assertNotNull(xmpXml);

      Debug.debug("xmpXml", xmpXml);
View Full Code Here

    //    Debug.debug("possible file", file);

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

      // boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
      // if (ignoreImageData)
      // continue;

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

      Map params = new HashMap();
      String xmpXml = new JpegImageParser().getXmpXml(byteSource, params);
View Full Code Here

      boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
      if (ignoreImageData)
        continue;

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

      {
        JpegImageMetadata metadata = (JpegImageMetadata) Sanselan
View Full Code Here

      boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
      if (ignoreImageData)
        continue;

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

        boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
        if (ignoreImageData)
          continue;

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

        JpegImageMetadata oldMetadata = (JpegImageMetadata) Sanselan
            .getMetadata(imageFile);
View Full Code Here

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

      ByteSource byteSource = new ByteSourceFile(imageFile);

      Map params = new HashMap();
      boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
      params
          .put(PARAM_KEY_READ_THUMBNAILS, new Boolean(
View Full Code Here

      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));
      // params.put(PARAM_KEY_VERBOSE, Boolean.TRUE);
      // params.put(PARAM_KEY_VERBOSE, Boolean.TRUE);

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

      File noIptcFile = createTempFile(imageFile.getName()
          + ".iptc.remove.", ".jpg");
      {
        // test remove

        OutputStream os = null;
        try
        {
          os = new FileOutputStream(noIptcFile);
          os = new BufferedOutputStream(os);
          new JpegIptcRewriter().removeIPTC(byteSource, os);
        } finally
        {
          os.close();
          os = null;
        }

        // Debug.debug("Source Segments:");
        // new JpegUtils().dumpJFIF(new ByteSourceFile(noIptcFile));

        JpegPhotoshopMetadata outMetadata = new JpegImageParser()
            .getPhotoshopMetadata(new ByteSourceFile(noIptcFile),
                params);
        assertTrue(outMetadata == null
            || outMetadata.getItems().size() == 0);
      }
      {
        // test no-change update

        List newBlocks = metadata.photoshopApp13Data.getNonIptcBlocks();
        List oldRecords = metadata.photoshopApp13Data.getRecords();
        List 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.update.", ".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("Source 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()
        // .hasIptcSegment(updateByteSource));

        assertNotNull(outMetadata);
        assertTrue(outMetadata.getItems().size() == newRecords.size());
        // assertEquals(metadata.toString(), outMetadata.toString());
      }

      {
        // test update

        List newBlocks = metadata.photoshopApp13Data.getNonIptcBlocks();
        List newRecords = new ArrayList();

        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.update.", ".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("Source 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()
        // .hasIptcSegment(updateByteSource));

        assertNotNull(outMetadata);
        assertTrue(outMetadata.getItems().size() == 2);
        // assertEquals(metadata.toString(), outMetadata.toString());
      }

      {
        // test insert

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

        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.insert.", ".jpg");
        OutputStream os = null;
        try
        {
          os = new FileOutputStream(updated);
          os = new BufferedOutputStream(os);
          new JpegIptcRewriter().writeIPTC(new ByteSourceFile(
              noIptcFile), os, newData);
        } finally
        {
          os.close();
          os = null;
        }

        // Debug.debug("Source 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

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.