Hi
In your code to are adding images to the original file, rather than replacing them, so naturally the file will be bigger than the original.
If you want to convert the TIFF try using:
var
InImage,
OutImage : TIETIFFHandler;
Stream: TStream;
Bitmap: TIEBitmap;
IO: TImageEnIO;
i2: Integer;
begin
InImage := TIETIFFHandler.Create;
OutImage := TIETIFFHandler.Create;
Stream := TMemoryStream.Create;
Bitmap := TIEBitmap.Create;
IO := TImageEnIO.CreateFromBitmap(Bitmap);
try
if not InImage.ReadFile(In_File) or (InImage.GetPagesCount <= 0) then
raise Exception.Create('Fehler beim Lesen von Datei.');
for i2 := 0 to InImage.GetPagesCount - 1 do
begin
Stream.Size := 0;
InImage.WriteStream(Stream, i2);
Stream.Position := 0;
IO.LoadFromStream(Stream);
if IO.Aborting then
raise Exception.CreateFmt('Seiten-Ladefehler (%d)', [i2]);
// JPEG Quality 25%
IO.Params.TIFF_Compression := ioTIFF_JPEG;
IO.Params.TIFF_JPEGQuality := 25;
Stream.Size := 0;
IO.SaveToStreamTIFF(Stream);
Stream.Position := 0;
if not OutImage.InsertPageAsStream(Stream, i2) then
raise Exception.CreateFmt('Seiten-Speicherfehler (%d)', [i2]);
end;
try
OutImage.WriteFile(Out_File);
TFile.SetLastWriteTimeUtc(Temp, TFile.GetLastWriteTimeUtc(List[i]));
except
on E: Exception do
raise Exception.Create('Fehler beim Speichern der Datei.' + E.Message);
end;
finally
InImage.Free;
OutImage.Free;
Stream.Free;
Bitmap.Free;
IO.Free;
end;
end;
Nigel
Xequte Software
www.xequte.com
nigel@xequte.com