ImageEn, unit iexBitmaps

JpegLosslessTransformStream


Declaration

function JpegLosslessTransformStream(SourceStream, DestStream: TStream; Transform: TIEJpegTransform; GrayScale: Boolean; CopyMarkers: TIEJpegCopyMarkers; CutRect: Trect; UpdateEXIF: Boolean = True): Boolean;


Description

Losslessly rotates, flips or crops (cuts) a JPEG in a stream.


Description

Parameter Description
SourceStream A TStream object that contains the jpeg source stream
DestStream A TStream object that will receive the jpeg result stream
Transform The transformation to perform
GrayScale True force grayscale output
CopyMarkers How comments and markers (e.g. IPTC info) should be copied
CutRect Specifies the rectangle to retain when Transform = jtCut
UpdateEXIF Updates the EXIF thumbnail and orientation tags

Returns false if the operation failed.

Note: Rotation direction is the opposite to standard ImageEn Rotate. jtRotate90 means rotate 90° clockwise


Lossless Information

Whenever you save a JPEG by regular methods it needs to re-encoded, so after multiple re-saves the quality can become quite degraded. Lossless JPEG operations, on the other hand, work by rearranging the compressed data, without ever fully decoding the image, therefore there is no degration in quality.
Note, however, that lossless operations can only work on full DCT blocks, so when cutting/cropping the resulting image may contain at least a part of the area outside CutRect depending on the need to align with to the nearest DCT block boundary (or multiple blocks, depending on the sampling factors).



Examples

// Rotate input stream 90° clockwise and save to output strean
JPEGLosslessRotateFile( stream1, stream2, 270 );