infinity.image¶
Offers various image creation and manipulation possibilities. Lets you load image data from files or create your own. Supports different formats, quantizing, dithering, tone mapping algorithms as well as manipulation of basic image properties. Offers comfort functions for thumbnail creation, resizing, cropping, rotating, flipping and combining images as well as inverting, extracting or combining colors.
Module: infinity.image
The image functions are based on the FreeImage library. As in FreeImage, pixel rows are stored bottom-up: the row with the y-coordinate 0 is the bottom row of the image (this applies to getPixel(), setPixel(), getData() and setData()).
Example:
infinity.loadModule('infinity.image');
const WIDTH = 320;
const HEIGHT = 240;
let myImage = new infinity.image(infinity.image.type.bitmap, WIDTH, HEIGHT, 24);
myImage.fill(0x0000DDAA);
let color = 0x00CC0000;
const HWRATIO = HEIGHT / WIDTH;
for (let i = 0; i < WIDTH; i++){
//Diagonals
myImage.setPixel(i, i*HWRATIO, color);
myImage.setPixel(WIDTH-i, i*HWRATIO, color);
//Horizontal line
myImage.setPixel(i, HEIGHT/2, color);
//Vertical line
if( i <= HEIGHT ){
myImage.setPixel(WIDTH/2, i, color);
}
}
let myImage2 = new infinity.image();
myImage.copySubImage(140, 100, 180, 140, myImage2);
myImage.adjustGamma(1.5);
myImage.pasteSubImage(myImage2, 20, 20);
myImage.rotateEx(127, 0, -80, 160, 120, true);
myImage.saveToFile('image.bmp');
myImage2.free();
myImage.free();
image¶
The class for working with images.
Properties:
Methods:
- constructor()
- constructor()
- adaptiveThreshold()
- adjustBrightness()
- adjustContrast()
- adjustGamma()
- assign()
- clear()
- colorQuantize()
- combineChannels()
- convertTo16Bits555()
- convertTo16Bits565()
- convertTo24Bits()
- convertTo32Bits()
- convertTo4Bits()
- convertTo8Bits()
- convertToGrayscale()
- convertToRgbf()
- convertToStandardType()
- convertToType()
- copySubImage()
- deskew()
- dither()
- fill()
- flipHorizontal()
- flipVertical()
- free()
- getChannel()
- getData()
- getMetaData()
- getPixel()
- getThumbnail()
- invert()
- isGrayScale()
- isTransparent()
- isValid()
- loadFromFile()
- loadFromStream()
- pasteSubImage()
- rescale()
- rotate()
- rotateEx()
- saveToFile()
- saveToStream()
- setChannel()
- setData()
- setPixel()
- setSize()
- splitChannels()
- threshold()
- thumbnail()
- toneMapping()
Example:
infinity.loadModule('infinity.image');
let myImage = new infinity.image();
Properties
horzResolution¶
Type: number
Gets or sets the horizontal pixels per unit property.
vertResolution¶
Type: number
Gets or sets the vertical pixels per unit property.
bpp¶
Type: number
Gets the bits per pixel property.
color¶
Type: infinity.image.color
Gets the color model in use corresponding to the infinity.image.color enum.
colorsUsed¶
Type: number
Gets the number of possible colors (0 for true-color).
height¶
Type: number
Gets the height of the picture in pixels.
scanWidth¶
Type: number
Gets the width in bytes of each scan line (row) of pixel data.
size¶
Type: number
Gets the size of the image data in memory in bytes (not the size of an image file).
type¶
Type: infinity.image.type
Gets the image type according to infinity.image.type
width¶
Type: number
Gets the image width in pixels.
Methods
constructor()¶
Lets you create an INFINITY.JS image file object instance with several parameters. An image is only allocated if width, height and bpp are all greater than 0; otherwise the instance is empty.
Signature:
constructor( type?: infinity.image.type, width?: number, height?: number, bpp?: number )
Parameters:
-
type:
infinity.image.type, optionalImage type according to infinity.image.type. Default:
infinity.image.type.bitmap. Before version 3.11 the type was ignored and a standard bitmap was always created. -
width:
number, optionalImage width in pixels.
-
height:
number, optionalImage height in pixels.
-
bpp:
number, optionalBits per pixel.
Example:
infinity.loadModule('infinity.image');
let myImage = new infinity.image(infinity.image.type.bitmap, 640, 480, 24);
constructor()¶
Lets you create an empty INFINITY.JS image file object instance without parameters.
Signature:
constructor()
Example:
infinity.loadModule('infinity.image');
let myImage = new infinity.image();
myImage.loadFromFile('image.bmp');
myImage.convertToGrayscale();
myImage.dither(infinity.image.dither.fs);
myImage.saveToFile('image2.bmp');
adaptiveThreshold()¶
Converts an RGB 8-bit-color image to black and white using the adaptive threshold algorithm.
Signature:
adaptiveThreshold( s: number, t: number ): boolean
Parameters:
-
s:
numberWindow size.
-
t:
numberThreshold value for black and white.
Return type: boolean
Example:
myImage.adaptiveThreshold(64, 128);
adjustBrightness()¶
Adjusts image brightness.
Signature:
adjustBrightness( percentage: number ): boolean
Parameters:
- percentage:
numberAdjustment extent in percent.
Return type: boolean
Example:
myImage.adjustBrightness(70);
adjustContrast()¶
Adjusts image contrast.
Signature:
adjustContrast( percentage: number ): boolean
Parameters:
- percentage:
numberAdjustment extent in percent.
Return type: boolean
Example:
myImage.adjustContrast(50);
adjustGamma()¶
Adjusts image gamma.
Signature:
adjustGamma( gamma: number ): boolean
Parameters:
- gamma:
numberThe new gamma value.
Return type: boolean
Example:
myImage.adjustGamma(1.5);
assign()¶
Assigns the contents of another infinity.image object instance to the current object instance.
Signature:
assign( src: infinity.image ): void
Parameters:
- src:
infinity.imageThe
infinity.imageobject instance to assign the contents from.
Example:
let myImage = new infinity.image();
myImage.loadFromFile('image.bmp');
let myImage2 = new infinity.image();
myImage2.assign(myImage);
myImage2.saveToFile('image2.bmp');
clear()¶
Clears image data from the current object instance.
Signature:
clear(): void
Example:
myImage.clear();
colorQuantize()¶
Quantizates colors of the image data.
Signature:
colorQuantize( algorithm: infinity.image.quantize ): boolean
Parameters:
- algorithm:
infinity.image.quantizeThe quantization algorithm to apply according to
infinity.image.quantize.
Return type: boolean
Example:
myImage.colorQuantize(infinity.image.quantize.lfpQuant);
combineChannels()¶
Combines the red, green and blue channels from three 8-bit greyscale images into the current image.
Signature:
combineChannels( red: infinity.image, green: infinity.image, blue: infinity.image ): boolean
Parameters:
-
red:
infinity.imageRed channel.
-
green:
infinity.imageGreen channel.
-
blue:
infinity.imageBlue channel.
Return type: boolean
Example:
myImage.combineChannels(myImage2Red, myImage2Green, myImage2Blue);
convertTo16Bits555()¶
Converts a bitmap to 16 bits, where each pixel has a color pattern of 5 bits red, 5 bits green and 5 bits blue. One bit in each pixel is unused.
Signature:
convertTo16Bits555(): boolean
Return type: boolean
Example:
myImage.convertTo16Bits555();
convertTo16Bits565()¶
Converts a bitmap to 16 bits, where each pixel has a color pattern of 5 bits red, 6 bits green and 5 bits blue.
Signature:
convertTo16Bits565(): boolean
Return type: boolean
Example:
myImage.convertTo16Bits565();
convertTo24Bits()¶
Converts a bitmap to 24 bits.
Signature:
convertTo24Bits(): boolean
Return type: boolean
Example:
myImage.convertTo24Bits();
convertTo32Bits()¶
Converts a bitmap to 32 bits.
Signature:
convertTo32Bits(): boolean
Return type: boolean
Example:
myImage.convertTo32Bits();
convertTo4Bits()¶
Converts a bitmap to 4 bits.
Signature:
convertTo4Bits(): boolean
Return type: boolean
Example:
myImage.convertTo4Bits();
convertTo8Bits()¶
Converts a bitmap to 8 bits.
Signature:
convertTo8Bits(): boolean
Return type: boolean
Example:
myImage.convertTo8Bits();
convertToGrayscale()¶
Converts a bitmap to 8-bit greyscale.
Signature:
convertToGrayscale(): boolean
Return type: boolean
Example:
myImage.convertToGrayscale();
convertToRgbf()¶
Converts the bitmap to a 96-bit RGBF image.
Signature:
convertToRgbf(): boolean
Return type: boolean
Example:
myImage.convertToRgbf();
convertToStandardType()¶
Converts an image with a color type other than 8-bit (e.g. floating point color formats) to 8-bit grey scale.
Signature:
convertToStandardType( scaleLinear: boolean ): boolean
Parameters:
- scaleLinear:
booleanIf
true, then color values will be scaled linearly to values0-255. Iffalseeach value will be rounded to values0-255.
Return type: boolean
Example:
myImage.convertToStandardType(true);
convertToType()¶
Converts an image to the given color type.
Signature:
convertToType( type: infinity.image.type, scaleLinear: boolean ): boolean
Parameters:
-
type:
infinity.image.typeThe image type according to
infinity.image.type. -
scaleLinear:
booleanIf
true, then color values will be scaled linearly to values0-255. Iffalseeach value will be rounded to values0-255.
Return type: boolean
Example:
myImage.convertToType(infinity.image.type.rgba16, false);
copySubImage()¶
Copies a sub part of the current image.
Signature:
copySubImage( left: number, top: number, right: number, bottom: number, dest: infinity.image ): boolean
Parameters:
-
left:
numberSpecifies the left position of the cropped rectangle.
-
top:
numberSpecifies the top position of the cropped rectangle.
-
right:
numberSpecifies the right position of the cropped rectangle.
-
bottom:
numberSpecifies the bottom position of the cropped rectangle.
-
dest:
infinity.imageAn
infinity.imageobject instance to hold the copied image.
Return type: boolean
Example:
myImage.copySubImage(140, 100, 180, 140, myImage2);
deskew()¶
Deskews an image automatically.
Signature:
deskew( s: number, t: number ): boolean
Parameters:
-
s:
numberThe maximum deskew angle.
-
t:
numberLine detection threshold for the Hough lines algorithm.
Return type: boolean
Example:
myImage.deskew(10, 128);
dither()¶
Converts a bitmap to 1-bit monochrome bitmap using a dithering algorithm.
Signature:
dither( algorithm: infinity.image.dither ): boolean
Parameters:
- algorithm:
infinity.image.ditherThe dithering algorithm according to
infinity.image.dither.
Return type: boolean
Example:
myImage.dither(infinity.image.dither.fs);
fill()¶
Fills the whole image with the specified color. Throws an error if the image has an unsupported bit depth; does nothing if no image is allocated.
Signature:
fill( color: number ): void
Parameters:
- color:
numberThe color to be filled in. The format depends on the bit depth: for up to 8 bits per pixel a byte value (palette index or grey value; for 1 and 4 bits per pixel only the lowest 1 or 4 bits are used), for 16 bits the raw 16-bit value, for 24 bits
0xBBGGRR(red in the lowest byte), for 32 bits0xAARRGGBB, for 48 and 64 bits the raw pixel value.
Example:
myImage.fill(190904);
flipHorizontal()¶
Flips the image horizontally along the vertical axis.
Signature:
flipHorizontal(): boolean
Return type: boolean
Example:
myImage.flipHorizontal();
flipVertical()¶
Flips the image vertically along the horizontal axis.
Signature:
flipVertical(): boolean
Return type: boolean
Example:
myImage.flipVertical();
free()¶
Frees the memory previously occupied by the image object instance. The object must not be used afterwards: all other methods and properties then throw an error.
Signature:
free(): void
Example:
myImage.free();
getChannel()¶
Retrieves the specified channel of the image.
Signature:
getChannel( dest: infinity.image, channel: infinity.image.channel ): boolean
Parameters:
-
dest:
infinity.imageAn
infinity.imageobject instance to hold the output. -
channel:
infinity.image.channelThe color channel to extract according to
infinity.image.channel.
Return type: boolean
Example:
myImage.getChannel(myImage2, infinity.image.channel.green);
getData()¶
Returns the pixels of the image as an array of rows (data[y][x], bottom row first). The pixel values have the same format as for fill(). Returns undefined if no image is allocated; throws an error if the image has an unsupported bit depth. Before version 3.11 the red channel of 24- and 48-bit images was missing (blue was returned twice) and images with 1 or 4 bits per pixel were read as one byte per pixel.
Signature:
getData(): infinity.image.pixelArray
Return type: infinity.image.pixelArray
Example:
let pixelArray = myImage.getData();
pixelArray.forEach(element =>{
//...
});
getMetaData()¶
Returns the metadata of the image as an object with the properties comments, main, exif, gps, makernote, interop, iptc, xmp, geotiff, animation, custom and raw. Each of them is an object that maps the tag names of the respective metadata model to their values as strings.
Signature:
getMetaData(): any
Return type: any
Example:
let metaData = myImage.getMetaData();
console.debug(metaData.exif['DateTimeOriginal']);
getPixel()¶
Gets the color of the specified pixel (y-coordinate 0 is the bottom row). For images with up to 8 bits per pixel, the palette index is returned, otherwise the color as 0xAARRGGBB (alpha is only set for 32-bit images). Returns undefined if the pixel cannot be read (e.g. coordinates outside the image).
Signature:
getPixel( x: number, y: number ): number
Parameters:
-
x:
numberThe horizontal coordinate in pixels.
-
y:
numberThe vertical coordinate in pixels.
Return type: number
Example:
let color = myImage.getPixel(160, 120);
getThumbnail()¶
Retrieves the thumbnail possibly attached to the image (e.g. an EXIF thumbnail of a JPEG file). Returns false if no image is allocated or the image has no thumbnail.
Signature:
getThumbnail( dest: infinity.image ): boolean
Parameters:
- dest:
infinity.imageAn
infinity.imageobject instance to hold the output.
Return type: boolean
Example:
myImage.getThumbnail(myThumbObj);
invert()¶
Inverts the colors of the given image.
Signature:
invert(): boolean
Return type: boolean
Example:
myImage.invert();
isGrayScale()¶
Returns true if the image is a 8-bit bitmap with a greyscale palette, false otherwise.
Signature:
isGrayScale(): boolean
Return type: boolean
Example:
if(myImage.isGrayScale()){
//...
}
isTransparent()¶
Returns whether transparency is enabled.
Signature:
isTransparent(): boolean
Return type: boolean
Example:
if(myImage.isTransparent()){
//...
}
isValid()¶
Returns true if the image is allocated, false otherwise.
Signature:
isValid(): boolean
Return type: boolean
Example:
if(myImage.isValid()){
//...
}
loadFromFile()¶
Loads the image from the specified file into the object instance. The image format is detected automatically. Returns false if the image cannot be loaded.
Signature:
loadFromFile( fileName: string, flag?: infinity.image.flag ): boolean
Parameters:
-
fileName:
stringFilename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which has to be loaded.
-
flag:
infinity.image.flag, optionalOne or a combination of the
infinity.image.flagload flags for the respective format. Default:0.
Return type: boolean
Example:
myImage.loadFromFile('image.bmp');
loadFromStream()¶
Loads the image from the specified stream into the object instance. The image format is detected automatically. Returns false if the image cannot be loaded.
Signature:
loadFromStream( stream: infinity.stream, flag?: infinity.image.flag ): boolean
Parameters:
-
stream:
infinity.streamStream object to load from. See infinity.stream.
-
flag:
infinity.image.flag, optionalOne or a combination of the
infinity.image.flagload flags for the respective format. Default:0.
Return type: boolean
Example:
myImage.loadFromStream(stream);
pasteSubImage()¶
Alpha blends or combines a sub part image with the current image.
Signature:
pasteSubImage( src: infinity.image, left: number, top: number, alpha?: number ): boolean
Parameters:
-
src:
infinity.imageSource subimage.
-
left:
numberSpecifies the left position of the sub image.
-
top:
numberSpecifies the top position of the sub image.
-
alpha:
number, optionalAlpha blend factor. The source and destination images are alpha blended if alpha = 0..255. If alpha > 255, then the source image is combined to the destination image. Default:
256.
Return type: boolean
Example:
myImage.pasteSubImage(myImage2, 20, 20);
rescale()¶
Rescales the image to a new width / height.
Signature:
rescale( width: number, height: number, filter: infinity.image.filter, dest?: infinity.image ): boolean
Parameters:
-
width:
numberNew image width.
-
height:
numberNew image height.
-
filter:
infinity.image.filterThe filter parameter specifies which resampling filter should be used according to
infinity.image.filter. -
dest:
infinity.image, optionalAn
infinity.imageobject instance to hold the output. If omitted, the current image is replaced by the rescaled image.
Return type: boolean
Example:
myImage.rescale(160, 120, infinity.image.filter.lanczos3);
rotate()¶
Rotates the image.
Signature:
rotate( angle: number ): boolean
Parameters:
- angle:
numberImage rotation angle, in degree.
Return type: boolean
Example:
myImage.rotate(90);
rotateEx()¶
Image translation and rotation using B-Splines.
Signature:
rotateEx( angle: number, xShift: number, yShift: number, xOrigin: number, yOrigin: number, useMask: boolean ): boolean
Parameters:
-
angle:
numberImage rotation angle, in degree.
-
xShift:
numberImage horizontal shift.
-
yShift:
numberImage vertical shift.
-
xOrigin:
numberOrigin of the x-axis.
-
yOrigin:
numberOrigin of the y-axis.
-
useMask:
booleanWhether or not to mask the image. Image mirroring is applied when use_mask is set to FALSE.
Return type: boolean
Example:
myImage.rotateEx(127, 0, -80, 160, 120, true);
saveToFile()¶
Saves the image from the object instance to the specified file. The image format is determined by the file extension. Returns false if the image cannot be saved (e.g. if the format doesn't support the bit depth of the image).
Signature:
saveToFile( fileName: string, flag?: infinity.image.flag ): boolean
Parameters:
-
fileName:
stringFilename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which should contain the image output.
-
flag:
infinity.image.flag, optionalOne or a combination of the
infinity.image.flagsave flags for the respective format. Default:0.
Return type: boolean
Example:
myImage.saveToFile('image.bmp');
saveToStream()¶
Saves the image from the object instance to the specified stream. Returns false if the format is unknown or the image cannot be saved in this format (e.g. because of its bit depth). Throws an error if extension is empty.
Signature:
saveToStream( stream: infinity.stream, extension: string, flag?: infinity.image.flag ): boolean
Parameters:
-
stream:
infinity.streamStream object to save to. See infinity.stream.
-
extension:
stringA file extension determining the image format, with or without leading dot (e.g.
'png'or'.jpg'). -
flag:
infinity.image.flag, optionalOne or a combination of the
infinity.image.flagsave flags for the respective format. Default:0.
Return type: boolean
Example:
infinity.loadModule('infinity.stream');
let stream = new infinity.stream();
if ( myImage.saveToStream(stream, 'jpg', infinity.image.flag.jpeg_qualitygood) ) {
//...
}
setChannel()¶
Inserts a 8-bit dib into a 24- or 32-bit image.
Signature:
setChannel( src: infinity.image, channel: infinity.image.channel ): boolean
Parameters:
-
src:
infinity.imageInput 8-bit image to insert.
-
channel:
infinity.image.channelColor channel to replace.
Return type: boolean
Example:
myImage.setChannel(myImage2, infinity.image.channel.green);
setData()¶
Applies data from a pixel array to the image. The image must already be allocated with the matching size; the array must contain one row per image row (data[y][x], bottom row first), otherwise an error is thrown. The pixel values have the same format as for fill().
Signature:
setData( data: infinity.image.pixelArray ): void
Parameters:
- data:
infinity.image.pixelArrayThe pixel array to apply, e.g. as returned by getData().
Example:
myImage.setData(pixelArray);
setPixel()¶
Sets the pixel color of an image at position (x, y), where y-coordinate 0 is the bottom row. For images with up to 8 bits per pixel, color is the palette index, otherwise the color as 0xAARRGGBB (see getPixel()).
Signature:
setPixel( x: number, y: number, color: number ): void
Parameters:
-
x:
numberPixel position in horizontal direction.
-
y:
numberPixel position in vertical direction.
-
color:
numberPixel color.
Example:
myImage.setPixel(160, 120, 190904);
setSize()¶
Allocates a new, empty image with the given type, width, height and bits per pixel, replacing the current image. Returns false if width, height or bpp is not greater than 0 or the image cannot be allocated.
Signature:
setSize( type: infinity.image.type, width: number, height: number, bpp: number ): boolean
Parameters:
-
type:
infinity.image.typeImage type according to infinity.image.type.
-
width:
numberNew image width in pixels.
-
height:
numberNew image height in pixels.
-
bpp:
numberBits per pixel.
Return type: boolean
Example:
myImage.setSize(infinity.image.type.bitmap, 640, 480, 32);
splitChannels()¶
Splits a 24-bit RGB image into 3 greyscale images corresponding to the red, green and blue channels.
Signature:
splitChannels( red: infinity.image, green: infinity.image, blue: infinity.image ): boolean
Parameters:
-
red:
infinity.imageAn
infinity.imageobject instance to hold the output red channel. -
green:
infinity.imageAn
infinity.imageobject instance to hold the output green channel. -
blue:
infinity.imageAn
infinity.imageobject instance to hold the output blue channel.
Return type: boolean
Example:
myImage.splitChannels(myImage2Red, myImage2Green, myImage2Blue);
threshold()¶
Converts the bitmap to 1 bit using a threshold.
Signature:
threshold( value: number ): boolean
Parameters:
- value:
numberThreshold value in [0..255].
Return type: boolean
Example:
myImage.threshold(127);
thumbnail()¶
Creates a thumbnail out of the picture inside the object instance and stores it in dest. The current image is not changed.
Signature:
thumbnail( width: number, height: number, dest: infinity.image ): void
Parameters:
-
width:
numberThumbnail width.
-
height:
numberThumbnail height.
-
dest:
infinity.imageAn
infinity.imageobject instance to hold the output.
Example:
myImage.thumbnail(30, 20, myThumbObj);
toneMapping()¶
Converts a High Dynamic Range image to an image with a more limited dynamic range.
Signature:
toneMapping( tmo: infinity.image.tmo, firstParam: number, secondParam: number ): boolean
Parameters:
-
tmo:
infinity.image.tmoTone mapping operator according to
infinity.image.tmo. -
firstParam:
numberFirst tone mapping algorithm parameter (algorithm dependant).
-
secondParam:
numberSecond tone mapping algorithm parameter (algorithm dependant).
Return type: boolean - false if the image cannot be converted. fattal02 returns false for images smaller than 32 pixels in width or height (FreeImage crashes there).
Example:
myImage.toneMapping(infinity.image.tmo.drago03, firstParam, secondParam);
pixelArray¶
Extends: Array<Array<number>>
A two-dimensional array of pixel values: an array of rows (bottom row first), each an array of the pixel values of that row.
infinity.image.channel¶
Values:
-
rgb:
0Use red, green and blue channels.
-
red:
1Use red channel.
-
green:
2Use green channel.
-
blue:
3Use blue channel.
-
alpha:
4Use alpha channel.
-
black:
5Use black channel.
-
real:
6Complex images: use real part.
-
imag:
7Complex images: use imaginary part.
-
mag:
8Complex images: use magnitude.
-
phase:
9Complex images: use phase.
Example:
infinity.loadModule('infinity.image');
let channel = infinity.image.channel.rgb;
infinity.image.color¶
Values:
-
minIsWhite:
0Min value is white.
-
minIsBlack:
1Min value is black.
-
rgb:
2RGB color model.
-
palette:
3Color map indexed.
-
rgbAlpha:
4RGB color model with alpha channel.
-
cmyk:
5CMYK color model.
Example:
infinity.loadModule('infinity.image');
let color = infinity.image.color.minIsWhite;
infinity.image.dither¶
Values:
-
fs:
0Floyd and Steinberg error diffusion.
-
bayer4x4:
1Bayer ordered dispersed dot dithering (order 2 dithering matrix).
-
bayer8x8:
2Bayer ordered dispersed dot dithering (order 3 dithering matrix).
-
cluster6x6:
3Ordered clustered dot dithering (order 3 - 6x6 matrix).
-
cluster8x8:
4Ordered clustered dot dithering (order 4 - 8x8 matrix).
-
cluster16x16:
5Ordered clustered dot dithering (order 8 - 16x16 matrix).
-
bayer16x16:
6Bayer ordered dispersed dot dithering (order 4 dithering matrix).
Example:
infinity.loadModule('infinity.image');
let dither = infinity.image.dither.fs;
infinity.image.filter¶
Values:
-
box:
0Box, pulse, Fourier window, 1st order (constant) b-spline.
-
bicubic:
1Mitchell and Netravali's two-param cubic filter.
-
bilinear:
2Bilinear filter.
-
bspline:
34th order (cubic) b-spline.
-
catmullrom:
4Catmull-Rom spline, Overhauser spline.
-
lanczos3:
5Lanczos3 filter.
Example:
infinity.loadModule('infinity.image');
let filter = infinity.image.filter.box;
infinity.image.flag¶
Values:
-
fif_load_nopixels = 0x8000
Loading: load the image header only.
-
bmp_default = 0
-
bmp_save_rle = 1
-
cut_default = 0
-
dds_default = 0
-
exr_default = 0
Save data as half with piz-based wavelet compression.
-
exr_float = 0x0001
Save data as float instead of as half.
-
exr_none = 0x0002
Save with no compression.
-
exr_zip = 0x0004
Save with zlib compression, in blocks of 16 scan lines.
-
exr_piz = 0x0008
Save with piz-based wavelet compression.
-
exr_pxr24 = 0x0010
Save with lossy 24-bit float compression.
-
exr_b44 = 0x0020
Save with lossy 44% float compression - goes to 22% when combined with EXR_LC.
-
exr_lc = 0x0040
Save images with one luminance and two chroma channels, rather than as RGB (lossy compression).
-
faxg3_default = 0
-
gif_default = 0
-
gif_load256 = 1
Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color.
-
gif_playback = 2
'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading.
-
hdr_default = 0
-
ico_default = 0
-
ico_makealpha = 1
Convert to 32bpp and create an alpha channel from the AND-mask when loading.
-
iff_default = 0
-
j2k_default = 0
Save with a 16:1 rate.
-
jp2_default = 0
Save with a 16:1 rate.
-
jpeg_default = 0
Loading (see JPEG_FAST); saving (see JPEG_QUALITYGOOD|JPEG_SUBSAMPLING_420).
-
jpeg_fast = 1
Load the file as fast as possible, sacrificing some quality.
-
jpeg_accurate = 2
Load the file with the best quality, sacrificing some speed.
-
jpeg_cmyk = 0x0004
Load separated CMYK "as is" (use | to combine with other flags).
-
jpeg_exifrotate = 0x0008
Load and rotate according to Exif 'Orientation' tag if available.
-
jpeg_greyscale = 0x0010
Load and convert to a 8-bit greyscale image.
-
jpeg_qualitysuperb = 0x0080
Save with superb quality (100:1).
-
jpeg_qualitygood = 0x0100
Save with good quality (75:1).
-
jpeg_qualitynormal = 0x0200
Save with normal quality (50:1).
-
jpeg_qualityaverage = 0x0400
Save with average quality (25:1).
-
jpeg_qualitybad = 0x0800
Save with bad quality (10:1).
-
jpeg_progressive = 0x2000
Save as a progressive-JPEG (use | to combine with other save flags).
-
jpeg_subsampling_411 = 0x1000
Save with high 4x1 chroma subsampling (4:1:1).
-
jpeg_subsampling_420 = 0x4000
Save with medium 2x2 medium chroma subsampling (4:2:0) - default value.
-
jpeg_subsampling_422 = 0x8000
Save with low 2x1 chroma subsampling (4:2:2).
-
jpeg_subsampling_444 = 0x10000
Save with no chroma subsampling (4:4:4).
-
jpeg_optimize = 0x20000
On saving, compute optimal Huffman coding tables (can reduce a few percent of file size).
-
jpeg_baseline = 0x40000
Save basic JPEG, without metadata or any markers.
-
koala_default = 0
-
lbm_default = 0
-
mng_default = 0
-
pcd_default = 0
-
pcd_base = 1
Load the bitmap sized 768 x 512.
-
pcd_basediv4 = 2
Load the bitmap sized 384 x 256.
-
pcd_basediv16 = 3
Load the bitmap sized 192 x 128.
-
pcx_default = 0
-
pfm_default = 0
-
pict_default = 0
-
png_default = 0
-
png_ignoregamma = 1
Loading: avoid gamma correction.
-
png_z_best_speed = 0x0001
Save using ZLib level 1 compression flag (default value is 6).
-
png_z_default_compression = 0x0006
Save using ZLib level 6 compression flag (default recommended value).
-
png_z_best_compression = 0x0009
Save using ZLib level 9 compression flag (default value is 6).
-
png_z_no_compression = 0x0100
Save without ZLib compression.
-
png_interlaced = 0x0200
Save using Adam7 interlacing (use | to combine with other save flags).
-
pnm_default = 0
-
pnm_save_raw = 0
If set the writer saves in RAW format (i.e. P4, P5 or P6).
-
pnm_save_ascii = 1
If set the writer saves in ASCII format (i.e. P1, P2 or P3).
-
psd_default = 0
-
psd_cmyk = 1
Reads tags for separated CMYK (default is conversion to RGB).
-
psd_lab = 2
Reads tags for CIELab (default is conversion to RGB).
-
psd_none = 0x0100
Save without any compression.
-
psd_rle = 0x0200
Save using RLE compression.
-
psd_psb = 0x2000
Save using Adobe Large Document Format (use | to combine with other save flags).
-
ras_default = 0
-
raw_default = 0
Load the file as linear RGB 48-bit.
-
raw_preview = 1
Try to load the embedded JPEG preview with included Exif Data or default to RGB 24-bit.
-
raw_display = 2
Load the file as RGB 24-bit.
-
raw_halfsize = 4
Output a half-size color image.
-
raw_unprocessed = 8
Output a FIT_UINT16 raw Bayer image.
-
sgi_default = 0
-
targa_default = 0
-
targa_load_rgb888 = 1
If set the loader converts RGB555 and ARGB8888 -> RGB888.
-
targa_save_rle = 2
If set, the writer saves with RLE compression.
-
tiff_default = 0
-
tiff_cmyk = 0x0001
Reads/stores tags for separated CMYK (use | to combine with compression flags).
-
tiff_packbits = 0x0100
Save using PACKBITS compression.
-
tiff_deflate = 0x0200
Save using DEFLATE compression.
-
tiff_adobe_deflate = 0x0400
Save using ADOBE DEFLATE compression.
-
tiff_none = 0x0800
Save without any compression.
-
tiff_ccittfax3 = 0x1000
Save using CCITT Group 3 fax encoding.
-
tiff_ccittfax4 = 0x2000
Save using CCITT Group 4 fax encoding.
-
tiff_lzw = 0x4000
Save using LZW compression.
-
tiff_jpeg = 0x8000
Save using JPEG compression.
-
tiff_logluv = 0x10000
Save using LogLuv compression.
-
wbmp_default = 0
-
xbm_default = 0
-
xpm_default = 0
-
webp_default = 0
Save with good quality (75:1).
-
webp_lossless = 0x100
Save in lossless mode.
-
jxr_default = 0
Save with quality 80 and no chroma subsampling (4:4:4).
-
jxr_lossless = 0x0064
Save lossless.
-
jxr_progressive = 0x2000
Save as a progressive-JXR (use | to combine with other save flags).
Example:
infinity.loadModule('infinity.image');
let flag = infinity.image.flag.bmp_default;
infinity.image.quantize¶
Values:
-
wuQuant:
0Xiaolin Wu color quantization algorithm.
-
nnQuant:
1NeuQuant neural-net quantization algorithm by Anthony Dekker.
-
lfpQuant:
2Lossless Fast Pseudo-Quantization Algorithm.
Example:
infinity.loadModule('infinity.image');
let quantize = infinity.image.quantize.wuQuant;
infinity.image.tmo¶
Values:
-
drago03:
0Adaptive logarithmic mapping (F. Drago, 2003).
-
reinhard05:
1Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005).
-
fattal02:
2Gradient domain high dynamic range compression (R. Fattal, 2002).
Example:
infinity.loadModule('infinity.image');
let tmo = infinity.image.tmo.drago03;
infinity.image.type¶
Values:
-
unknown:
0Unknown type.
-
bitmap:
1Standard image : 1-, 4-, 8-, 16-, 24-, 32-bit.
-
uint16:
2Array of unsigned short : unsigned 16-bit.
-
int16:
3Array of short : signed 16-bit.
-
uint32:
4Array of unsigned long : unsigned 32-bit.
-
int32:
5Array of long : signed 32-bit.
-
float:
6Array of float : 32-bit IEEE floating point.
-
double:
7Array of double : 64-bit IEEE floating point.
-
complex:
8Array of FICOMPLEX : 2 x 64-bit IEEE floating point.
-
rgb16:
948-bit RGB image : 3 x 16-bit.
-
rgba16:
1064-bit RGBA image : 4 x 16-bit.
-
rgbf:
1196-bit RGB float image : 3 x 32-bit IEEE floating point.
-
rgbaf:
12128-bit RGBA float image : 4 x 32-bit IEEE floating point.
Example:
infinity.loadModule('infinity.image');
let type = infinity.image.type.bitmap;