Hi
Yes, ImageEn should be fully thread safe in that situation.
We tried embedding your code inside a TThread and to execute it continuously (code below). The resulting jpeg is always good.
It seems that the produced file has some bytes corrupted. So saving may be working correctly (interrupted by something?) or there another processing is writing the same file.
Some questions:
1) How many threads do you run concurrently?
2) Is it possible that the background thread is stopped for some reason (maybe by closing a form or the application)?
type
TMyThread = class(TThread)
private
public
constructor Create(CreateSuspended:Boolean);
procedure Execute(); override;
end;
var
mythread: TMyThread;
procedure TForm1.Button1Click(Sender: TObject);
begin
mythread := TMyThread.Create(false);
end;
constructor TMyThread.Create(CreateSuspended:Boolean);
begin
inherited Create;
end;
procedure TMyThread.Execute();
var
io: timageenio;
ieParams: TIOParams;
AFileName, OFileName: string;
begin
AFileName := 'C:\DSC04031.JPG';
OFileName := 'c:\test.jpeg';
while True do
begin
io := TImageEnIO.Create(nil);
try
ieParams := io.Params;
io.ParamsFromFile(AFileName);
//do not change jpeg quality to lower
io.Params.JPEG_Quality := 100;
if ieParams.EXIF_HasEXIFData and
((ieParams.EXIF_Orientation <> 0) or (ieParams.TIFF_Orientation <> 0))
then
begin
ieParams.EnableAdjustOrientation := true;
io.LoadFromFile(AFileName);
ieParams.EXIF_Orientation := 0;
ieParams.TIFF_Orientation := 0;
ieParams.EXIF_Bitmap.Clear;
io.SaveToFile(OFileName);
end;
finally
io.Free;
end;
end;
end;
Nigel
Xequte Software
www.imageen.com