Declaration
function JpegLosslessTransform(const SourceFile, DestFile: WideString; Transform: TIEJpegTransform; UpdateEXIF: Boolean = True): boolean; overload;
function JpegLosslessTransform(const SourceFile, DestFile: WideString; Transform: TIEJpegTransform; GrayScale: Boolean; CopyMarkers: TIEJpegCopyMarkers; CutRect: TRect; UpdateEXIF: Boolean = True): Boolean; overload;
function JpegLosslessTransform(const SourceFile, DestFile: WideString; RotateAngle: Integer; UpdateEXIF: Boolean = True): boolean; overload;
function JpegLosslessTransform(const SourceFile, DestFile: WideString; Direction: TFlipDir; UpdateEXIF: Boolean = True): boolean; overload;
Description
Losslessly rotates, flips or crops (cuts) a JPEG file.
Description
Parameter | Description |
SourceFile | The full path and filename of the source file |
DestFile | The full path and filename for the resulting file |
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 |
Returns false if the operation failed.
Note:
◼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
See also:
JpegLosslessTransform2 which works with a single file.
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).
| Demos\ImageEditing\LosslessJpegEdit\Lossless.dpr |
// Rotate input.jpg 90° clockwise and save to output.jpg
JpegLosslessTransform('D:\input.jpg', 'D:\output.jpg', jtRotate90, false, jcCopyAll, Rect(0, 0, 0, 0));
// Rotate input.jpeg 90° clockwise and save to output.jpeg
JPEGLosslessRotateFile('D:\input.jpeg', 'D:\output.jpeg', 270);