Pike v8.1 release 6

Method Image.JPEG.encode()


Method encode

string encode(object image)
string encode(string|object image, mapping options)

Description

Encodes an image object with JPEG compression. The image may also be a string containing a raw JPEG image. In the The options argument may be a mapping containing zero or more encoding options:

"quality" : int(0..100)

Set quality of result. Default is 75.

"optimize" : bool

Optimize Huffman table. Default is on (1) for images smaller than 50kpixels.

"progressive" : bool

Make a progressive JPEG. Default is off (0).

"grayscale" : bool

Make a grayscale JPEG instead of color (YCbCr).

"smooth" : int(1..100)

Smooth input. Value is strength.

"method" : int

DCT method to use. Any of IFAST, ISLOW, FLOAT, DEFAULT or FASTEST. DEFAULT and FASTEST is from the jpeg library, probably ISLOW and IFAST respectively.

"density_unit" : int(0..2)

The unit used for x_density and y_density.

0

No unit

1

dpi

2

dpcm

"x_density" : int

Density of image.

"y_density" : int
"comment" : string

Comment to be written in the JPEG file. Must not be a wide string.

"baseline" : bool

Force baseline output. Useful for quality<25. Default is off for quality<25.

"quant_tables" : mapping(int:array(array(int)))

Tune quantisation tables manually.

"marker" : mapping(int:string(8bit)|array(string(8bit)))

Application and comment markers; the integer should be one of Marker.COM, Marker.APP0, Marker.APP1, ..., Marker.APP15. The string is up to the application; most notable are Adobe and Photoshop markers.

"transform" : int

Lossless image transformation. Has only effect when supplying a JPEG file as indata.

FLIP_H

Flip image horizontally

FLIP_V

Flip image vertically

ROT_90

Rotate image 90 degrees clockwise

ROT_180

Rotate image 180 degrees clockwise

ROT_270

Rotate image 270 degrees clockwise

TRANSPOSE

Transpose image

TRANSVERSE

Transverse image

Note

Please read some about JPEG files. A quality setting of 100 does not mean the result is lossless.