Package org.apache.sanselan

Examples of org.apache.sanselan.ImageFormat


{

    protected static boolean isJpeg(File file) throws IOException,
            ImageReadException
    {
        ImageFormat format = Sanselan.guessFormat(file);
        return format == ImageFormat.IMAGE_FORMAT_JPEG;
    }
View Full Code Here


            throws ImageReadException, ImageWriteException, IOException
    {
        // read image
        BufferedImage image = Sanselan.getBufferedImage(file);

        ImageFormat format = ImageFormat.IMAGE_FORMAT_TIFF;
        Map params = new HashMap();

        // set optional parameters if you like
        params.put(SanselanConstants.PARAM_KEY_COMPRESSION, new Integer(
                TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED));
View Full Code Here

            BufferedImage image_4 = Sanselan.getBufferedImage(is);

            // <b>Write an image. </b>
            BufferedImage image = someImage;
            File dst = someFile;
            ImageFormat format = ImageFormat.IMAGE_FORMAT_PNG;
            Map optional_params = new HashMap();
            Sanselan.writeImage(image, dst, format, optional_params);

            OutputStream os = someOutputStream;
            Sanselan.writeImage(image, os, format, optional_params);

            // <b>get the image's embedded ICC Profile, if it has one. </b>
            byte iccProfileBytes[] = Sanselan.getICCProfileBytes(imageBytes);

            ICC_Profile iccProfile = Sanselan.getICCProfile(imageBytes);

            // <b>get the image's width and height. </b>
            Dimension d = Sanselan.getImageSize(imageBytes);

            // <b>get all of the image's info (ie. bits per pixel, size, transparency, etc.) </b>
            ImageInfo imageInfo = Sanselan.getImageInfo(imageBytes);

            if (imageInfo.getColorType() == ImageInfo.COLOR_TYPE_GRAYSCALE)
                System.out.println("Grayscale image.");
            if (imageInfo.getHeight() > 1000)
                System.out.println("Large image.");

            // <b>try to guess the image's format. </b>
            ImageFormat image_format = Sanselan.guessFormat(imageBytes);
            image_format.equals(ImageFormat.IMAGE_FORMAT_PNG);

            // <b>get all metadata stored in EXIF format (ie. from JPEG or TIFF). </b>
            // <b>org.w3c.dom.Node node = Sanselan.getMetadataObsolete(imageBytes); </b>
            IImageMetadata metdata = Sanselan.getMetadata(imageBytes);
View Full Code Here

    }

    private IconData readIconData(byte[] iconData, IconInfo fIconInfo)
            throws ImageReadException, IOException
    {
        ImageFormat imageFormat = Sanselan.guessFormat(iconData);
        if (imageFormat.equals(ImageFormat.IMAGE_FORMAT_PNG))
        {
            BufferedImage bufferedImage = Sanselan.getBufferedImage(iconData);
            PNGIconData pngIconData = new PNGIconData(fIconInfo, bufferedImage);
            return pngIconData;
        }
View Full Code Here

{

    private static boolean isGif(File file) throws IOException,
            ImageReadException
    {
        ImageFormat format = Sanselan.guessFormat(file);
        return format == ImageFormat.IMAGE_FORMAT_GIF;
    }
View Full Code Here

                    "@broken"))
                checkGetImageInfo(imageFile, imageFileBytes);

            checkGetImageSize(imageFile, imageFileBytes);

            ImageFormat imageFormat = Sanselan.guessFormat(imageFile);
            if (ImageFormat.IMAGE_FORMAT_JPEG == imageFormat
                    || ImageFormat.IMAGE_FORMAT_UNKNOWN == imageFormat)
                ;
            else
                checkGetBufferedImage(imageFile, imageFileBytes);
View Full Code Here

    public void checkGuessFormat(File imageFile, byte[] imageFileBytes)
            throws IOException, ImageReadException
    {
        // check guessFormat()
        ImageFormat imageFormatFile = Sanselan.guessFormat(imageFile);
        assertNotNull(imageFormatFile);
        assertTrue(imageFormatFile != ImageFormat.IMAGE_FORMAT_UNKNOWN);
        // Debug.debug("imageFormatFile", imageFormatFile);

        ImageFormat imageFormatBytes = Sanselan.guessFormat(imageFileBytes);
        assertNotNull(imageFormatBytes);
        assertTrue(imageFormatBytes != ImageFormat.IMAGE_FORMAT_UNKNOWN);
        // Debug.debug("imageFormatBytes", imageFormatBytes);

        assertTrue(imageFormatBytes == imageFormatFile);
View Full Code Here

            throws IOException, ImageReadException, IllegalAccessException,
            IllegalArgumentException, InvocationTargetException
    {
        Map params = new HashMap();
        boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
        ImageFormat imageFormat = Sanselan.guessFormat(imageFile);
        if (imageFormat.equals(ImageFormat.IMAGE_FORMAT_TIFF)
                || imageFormat.equals(ImageFormat.IMAGE_FORMAT_JPEG))
            params
                    .put(PARAM_KEY_READ_THUMBNAILS, new Boolean(
                            !ignoreImageData));

        ImageInfo imageInfoFile = Sanselan.getImageInfo(imageFile, params);
View Full Code Here

{

    private static boolean isPng(File file) throws IOException,
            ImageReadException
    {
        ImageFormat format = Sanselan.guessFormat(file);
        return format == ImageFormat.IMAGE_FORMAT_PNG;
    }
View Full Code Here

{

    private static boolean isTiff(File file) throws IOException,
            ImageReadException
    {
        ImageFormat format = Sanselan.guessFormat(file);
        return format == ImageFormat.IMAGE_FORMAT_TIFF;
    }
View Full Code Here

TOP

Related Classes of org.apache.sanselan.ImageFormat

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.