Package org.apache.sanselan

Examples of org.apache.sanselan.ImageInfo


                colorType = ImageInfo.COLOR_TYPE_RGB;
            else if (colorType != ImageInfo.COLOR_TYPE_RGB &&
                    (paletteEntry.haveGray || paletteEntry.haveGray4Level))
                colorType = ImageInfo.COLOR_TYPE_GRAYSCALE;
        }
        return new ImageInfo("XPM version 3", xpmHeader.numCharsPerPixel * 8,
                new ArrayList(), ImageFormat.IMAGE_FORMAT_XPM,
                "X PixMap",
                xpmHeader.height, "image/x-xpixmap", 1,
                0, 0, 0, 0,
                xpmHeader.width, false, isTransparent, true,
View Full Code Here


                        + pngChunkIHDR.colorType);
            }

            String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_PNG_FILTER;

            ImageInfo result = new PngImageInfo(FormatDetails, BitsPerPixel,
                    comments, Format, FormatName, Height, MimeType,
                    NumberOfImages, PhysicalHeightDpi, PhysicalHeightInch,
                    PhysicalWidthDpi, PhysicalWidthInch, Width, isProgressive,
                    isTransparent, usesPalette, ColorType,
                    compressionAlgorithm, textChunks);
View Full Code Here

    }

    public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
            throws ImageReadException, IOException
    {
        ImageInfo imageInfo = getImageInfo(byteSource);
        if (imageInfo == null)
            return false;

        imageInfo.toString(pw, "");

        {
            ArrayList chunks = readChunks(byteSource, null, false);
            {
                ArrayList IHDRs = filterChunks(chunks, IHDR);
View Full Code Here

    public ImageInfo getImageInfo(ByteSource byteSource, Map params)
            throws ImageReadException, IOException
    {
        WbmpHeader wbmpHeader = readWbmpHeader(byteSource);
        return new ImageInfo("WBMP", 1, new ArrayList(),
                ImageFormat.IMAGE_FORMAT_WBMP,
                "Wireless Application Protocol Bitmap",
                wbmpHeader.height, "image/vnd.wap.wbmp", 1,
                0, 0, 0, 0,
                wbmpHeader.width, false, false, false,
View Full Code Here

      // detect attacks.
      if (response.getContentLength() < config.getMinThresholdBytes()) {
        return response;
      }

      ImageInfo imageInfo = Sanselan.getImageInfo(response.getResponse(), uri.getPath());

      boolean isOversizedImage = isImageTooLarge(imageInfo);
      if (isResizeRequested && isOversizedImage) {
        HttpResponseBuilder rejectedResponseBuilder = new HttpResponseBuilder()
            .setHttpStatusCode(HttpResponse.SC_FORBIDDEN)
            .setResponseString(RESIZE_IMAGE_TOO_LARGE);
        return rejectedResponseBuilder.create();
      }

      // Don't handle animations.
      // TODO: This doesn't work as current Sanselan doesn't return accurate image counts.
      // See animated GIF detection below.
      if (imageInfo.getNumberOfImages() > 1 || isOversizedImage) {
        return response;
      }
      int originalContentSize = response.getContentLength();
      totalSourceImageSize.addAndGet(originalContentSize);
      BufferedImage image = ImageIO.read(response.getResponse());

      if (isResizeRequested) {

        int origWidth = imageInfo.getWidth();
        int origHeight = imageInfo.getHeight();
        int widthDelta = 0;
        int heightDelta = 0;

        if (requestedWidth == null || requestedHeight == null) {
          // It is enough to cast only one int to double, Java will coerce all others to double
View Full Code Here

      // detect attacks.
      if (response.getContentLength() < config.getMinThresholdBytes()) {
        return response;
      }

      ImageInfo imageInfo = Sanselan.getImageInfo(response.getResponse(), uri.getPath());
     
      boolean noExpand = "1".equals(request.getParam(PARAM_NO_EXPAND));
      if (noExpand &&
          imageInfo.getHeight() <= requestedHeight &&
          imageInfo.getWidth() <= requestedWidth) {
        // Don't do anything, since the current image fits within the bounding area.
        isResizeRequested = false;
      }

      boolean isOversizedImage = isImageTooLarge(imageInfo);
      if (isResizeRequested && isOversizedImage) {
        HttpResponseBuilder rejectedResponseBuilder = new HttpResponseBuilder()
            .setHttpStatusCode(HttpResponse.SC_FORBIDDEN)
            .setResponseString(RESIZE_IMAGE_TOO_LARGE);
        return rejectedResponseBuilder.create();
      }

      // Don't handle animations.
      // TODO: This doesn't work as current Sanselan doesn't return accurate image counts.
      // See animated GIF detection below.
      if (imageInfo.getNumberOfImages() > 1 || isOversizedImage) {
        return response;
      }
      int originalContentSize = response.getContentLength();
      totalSourceImageSize.addAndGet(originalContentSize);
      BufferedImage image = readImage(imageFormat, response);

      if (isResizeRequested) {
        int origWidth = imageInfo.getWidth();
        int origHeight = imageInfo.getHeight();
        int widthDelta = 0;
        int heightDelta = 0;

        if (requestedWidth == null || requestedHeight == null) {
          // It is enough to cast only one int to double, Java will coerce all others to double
View Full Code Here

    else
      ColorType = ImageInfo.COLOR_TYPE_UNKNOWN;

    String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_JPEG;

    ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
        Format, FormatName, Height, MimeType, NumberOfImages,
        PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
        PhysicalWidthInch, Width, isProgressive, isTransparent,
        usesPalette, ColorType, compressionAlgorithm);
View Full Code Here

      throws ImageReadException, IOException
  {
    pw.println("tiff.dumpImageFile");

    {
      ImageInfo imageInfo = getImageInfo(byteSource);
      if (imageInfo == null)
        return false;

      imageInfo.toString(pw, "");
    }

    pw.println("");

    {
View Full Code Here

      break;
    default:
      compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_UNKNOWN;
    }

    ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
        Format, FormatName, Height, MimeType, NumberOfImages,
        PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
        PhysicalWidthInch, Width, isProgressive, isTransparent,
        usesPalette, ColorType, compressionAlgorithm);
View Full Code Here

  public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
      throws ImageReadException, IOException {
    pw.println("gif.dumpImageFile");

    {
      ImageInfo fImageData = getImageInfo(byteSource);
      if (fImageData == null)
        return false;

      fImageData.toString(pw, "");
    }
    {
      ImageContents imageContents = readImageContents(byteSource);

      imageContents.dump(pw);
View Full Code Here

TOP

Related Classes of org.apache.sanselan.ImageInfo

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.