Package org.apache.sanselan.formats.jpeg

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


            if (ignoreImageData)
                continue;

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

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

            {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                new ExifRewriter().removeExifMetadata(byteSource, baos);
                byte bytes[] = baos.toByteArray();
                File tempFile = createTempFile("test", ".jpg");
                Debug.debug("tempFile", tempFile);
                IOUtils.writeToFile(bytes, tempFile);

                Debug.debug("Output Segments:");
                new JpegUtils().dumpJFIF(new ByteSourceArray(bytes));

                assertTrue(!hasExifData(tempFile));
            }
        }
    }
View Full Code Here


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

                if (ignoreImageData)
                    continue;

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

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

    }

    public BufferedImage decode(ByteSource byteSource)
            throws IOException, ImageReadException
    {
        JpegUtils jpegUtils = new JpegUtils();
        jpegUtils.traverseJFIF(byteSource, this);
        if (imageReadException != null)
            throw imageReadException;
        if (ioException != null)
            throw ioException;
        return image;
View Full Code Here

        }
        return true;
      }
    };

    new JpegUtils().traverseJFIF(byteSource, visitor);

    //    GenericSegment exifSegment = exifSegmentArray[0];
    //    if (exifSegments.size() < 1)
    //    {
    //      // TODO: add support for adding, not just replacing.
View Full Code Here

      if (ignoreImageData)
        continue;

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

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

      {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        new ExifRewriter().removeExifMetadata(byteSource, baos);
        byte bytes[] = baos.toByteArray();
        File tempFile = File.createTempFile("test", ".jpg");
        Debug.debug("tempFile", tempFile);
        tempFile.deleteOnExit();
        IOUtils.writeToFile(bytes, tempFile);

        Debug.debug("Output Segments:");
        new JpegUtils().dumpJFIF(new ByteSourceArray(bytes));

        assertTrue(!hasExifData(tempFile));
      }
    }
  }
View Full Code Here

      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 = File.createTempFile("removed", ".jpg");
        Debug.debug("tempFile", tempFile);
        tempFile.deleteOnExit();
        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 = File.createTempFile("inserted" + "_", ".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);
View Full Code Here

        if (ignoreImageData)
          continue;

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

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

TOP

Related Classes of org.apache.sanselan.formats.jpeg.JpegUtils

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.