org.hd.d.pg2k.svrCore.mediahandler
Class gif

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.MIME.AbstractHandler
      extended by org.hd.d.pg2k.svrCore.MIME.AbstractImageHandler
          extended by org.hd.d.pg2k.svrCore.mediahandler.gif
All Implemented Interfaces:
Handler

public final class gif
extends AbstractImageHandler

Default handler for gif file (MIME type image/gif).


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.hd.d.pg2k.svrCore.MIME.Handler
Handler.ThumbnailParams
 
Field Summary
private static int EST_BYTES_PER_IMAGE_PIXEL_IN_MEMORY
          Estimated (maximum) bytes per pixel of a decoded image in memory.
private static int FILE_OVERHEAD
          Estimated file overhead constant, ie what would a 0x0 file size be; non-negative.
private static int maxThumbnailQuality
          Maximum quality allowed in a thumbnail; taken to be colour depth.
private static int minThumbnailQuality
          Maximum quality allowed in a thumbnail; taken to be colour depth.
private static int normalThumbnailQuality
          Normal/initial quality for a thumbnail.
private static int TARGET_BPP
          Target bits-per-pixel for thumbnail images; strictly positive.
private static Handler.ThumbnailParams thumbnailParams
          Gather together thumbnail parameters.
 
Fields inherited from interface org.hd.d.pg2k.svrCore.MIME.Handler
TAG_NAME_METADATA_TOP
 
Constructor Summary
gif()
           
 
Method Summary
protected  int _reduceColoursQualityThreshold()
          Guide colour-reduction to reduce quality and size of lossless image formats.
 java.awt.Dimension get2DImageDimensions(java.io.InputStream is)
          Get dimensions X and Y of a GIF exhibit, else null if dimensions cannot be computed.
 ExhibitMIME.ExhibitTypeParameters getExhibitType()
          Get internal type of ExhibitMIME type; never null.
 Handler.ThumbnailParams getThumbnailParams()
          Get ThumbnailParameters for GIF handler; non-null.
 
Methods inherited from class org.hd.d.pg2k.svrCore.MIME.AbstractImageHandler
_getEncoder, _trimMetadata, canMakeThumbnails, decodeImage, estimateWorkingMemoryToCreateThumbnails, extractSpecificImageMetaData, getMetadata, makeImageBinary, makeSizeConstrainedEncodedImage, makeThumbnailImage, makeThumbnails, makeThumbnails
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TARGET_BPP

private static final int TARGET_BPP
Target bits-per-pixel for thumbnail images; strictly positive. Does not need to leave all images perfect, but most should be OK. Note that we'll be limited from above by the absolute size limits of thumbnails in general.

A value in the range 4--8 is probably good.

See Also:
Constant Field Values

FILE_OVERHEAD

private static final int FILE_OVERHEAD
Estimated file overhead constant, ie what would a 0x0 file size be; non-negative. This factor helps avoid penalising small images by having the overhead eat into the bits that should be being used by the image.

One byte less than a 1x1 white image produced by PSP7.

See Also:
Constant Field Values

EST_BYTES_PER_IMAGE_PIXEL_IN_MEMORY

private static final int EST_BYTES_PER_IMAGE_PIXEL_IN_MEMORY
Estimated (maximum) bytes per pixel of a decoded image in memory. GIFs use a max-256-entry palette, so a reasonable in-memory representation will use one byte per pixel or less.

See Also:
Constant Field Values

maxThumbnailQuality

private static final int maxThumbnailQuality
Maximum quality allowed in a thumbnail; taken to be colour depth. Assume that this is the same as the maximum number of bits in memory we expect an image to take.

See Also:
Constant Field Values

normalThumbnailQuality

private static final int normalThumbnailQuality
Normal/initial quality for a thumbnail. This is reasonable for most images, though erring slightly on the side of retention of image quality at cost of download speed.

See Also:
Constant Field Values

minThumbnailQuality

private static final int minThumbnailQuality
Maximum quality allowed in a thumbnail; taken to be colour depth. Must be positive and can be as little as monochrome, ie one bit.

See Also:
Constant Field Values

thumbnailParams

private static final Handler.ThumbnailParams thumbnailParams
Gather together thumbnail parameters.

Constructor Detail

gif

public gif()
Method Detail

getExhibitType

public ExhibitMIME.ExhibitTypeParameters getExhibitType()
Get internal type of ExhibitMIME type; never null.


get2DImageDimensions

public java.awt.Dimension get2DImageDimensions(java.io.InputStream is)
                                        throws java.io.IOException
Get dimensions X and Y of a GIF exhibit, else null if dimensions cannot be computed. This reads the opening bytes of the exhibit directly to extract the dimensions, rather than loading and interpretting the whole image.

This input stream must be of the correct type, eg the magic number already checked.

This does not close its input stream when done.

Specified by:
get2DImageDimensions in interface Handler
Overrides:
get2DImageDimensions in class AbstractImageHandler
Parameters:
is - the exhibit as a binary data stream
Throws:
java.io.IOException - in case of problems with corrupt data (or a broken exhibit)

getThumbnailParams

public Handler.ThumbnailParams getThumbnailParams()
Get ThumbnailParameters for GIF handler; non-null.

Specified by:
getThumbnailParams in interface Handler
Overrides:
getThumbnailParams in class AbstractHandler

_reduceColoursQualityThreshold

protected int _reduceColoursQualityThreshold()
Description copied from class: AbstractImageHandler
Guide colour-reduction to reduce quality and size of lossless image formats. Defaults to -1, implying that the image format is a lossy format for which the ImageWriteParam.setCompressionQuality() mechanism is enough to trade encoded image size for quality.

Else this is a positive value n, typically 8 or 24, which sets a quality level at/below which the number of colours in the image is reduced to (capped at) 2^n, and the image representation may be tweaked too (eg converted to a palette/indexed format) as a strong hint to the encoder.

Overrides:
_reduceColoursQualityThreshold in class AbstractImageHandler

DHD Multimedia Gallery V1.60.69

Copyright (c) 1996-2012, Damon Hart-Davis. All rights reserved.