ImageEn, unit iexBitmaps

JpegLosslessTransform2

JpegLosslessTransform2


Declaration


function JpegLosslessTransform2(const FileName: WideString; Transform: TIEJpegTransform; UpdateEXIF: Boolean = True; ClearReadOnly: Boolean = False): boolean; overload;
function JpegLosslessTransform2(const FileName: WideString; Transform: TIEJpegTransform; GrayScale: boolean; CopyMarkers: TIEJpegCopyMarkers; CutRect: TRect; UpdateEXIF: Boolean = True; ClearReadOnly: Boolean = False): boolean; overload;
function JpegLosslessTransform2(const FileName: WideString; RotateAngle: Integer; UpdateEXIF: Boolean = True): boolean; overload;
function JpegLosslessTransform2(const FileName: WideString; Direction: TFlipDir; UpdateEXIF: Boolean = True): boolean; overload;


Description


Losslessly rotates, flips or crops (cuts) a JPEG file. Same as JpegLosslessTransform, but the source file is overwritten with the transformed image.


Description


Parameter Description
FileName The full path and filename of the file to transform
Transform The transformation to perform
GrayScale True force grayscale output
CopyMarkers How comments and markers (e.g. IPTC info) should be copied (Default: jcCopyAll)
CutRect Specifies the rectangle to retain when Transform = jtCut
UpdateEXIF Updates the EXIF thumbnail and orientation tags
ClearReadOnly If False and the file is marked Read-Only, conversion will fail


Returns false if the operation failed.

Notes:
- Rotation direction is the opposite to standard ImageEn Rotate. jtRotate90 means rotate 90 clockwise
- With RotateAngle overload, RotateAngle is a standard ImageEn rotation angle, e.g. 90 means rotate 90 counter-clockwise. Values other than -90, 90, 180, -180, 270 and -270 are ignored


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).


Demo


  Demos\ImageEditing\LosslessCrop\LosslessCut.dpr



Examples


// Rotate MyImage.jpg 90 clockwise
JpegLosslessTransform2('D:\MyImage.jpg', jtRotate90);

// Rotate MyImage.jpeg 90 clockwise
JPEGLosslessRotateFile('D:\MyImage.jpeg', 270);

// Flip MyImage.jpeg horizontally
JPEGLosslessRotateFile('D:\MyImage.jpeg', fdHorizontal);