FHannes Posted November 27, 2012 Share Posted November 27, 2012 I had to resize a lot of JPEG's to a long edge of 1000 pix and a thumbnail with a long edge of 200pix. If anyone is interested, here's the script I wrote to do it for me: [scar]var Files: TStrArray; Idx, Len: Integer; Bmp: TSCARBitmap; NewWidth, NewHeight, ThumbWidth, ThumbHeight: Integer; begin Files := GetFiles(ScriptPath, 'jpg'); Len := Length(Files); for Idx := 0 to Len - 1 do begin Bmp := TSCARBitmap.Create(''); try Bmp.LoadFromJpeg(ScriptPath + Files[idx]); if Bmp.Width > Bmp.Height then begin NewWidth := 1000; NewHeight := Bmp.Height * 1000 div Bmp.Width; ThumbWidth := 200; ThumbHeight := Bmp.Height * 200 div Bmp.Width; end else begin NewWidth := Bmp.Width * 1000 div Bmp.Height; NewHeight := 1000; ThumbWidth := Bmp.Width * 200 div Bmp.Height; ThumbHeight := 200; end; Bmp.Resize(NewWidth, NewHeight); Bmp.SaveToJpeg(ScriptPath + 'output\' + Copy(Files[idx], 1, Length(Files[idx]) - Length(ExtractFileExt(Files[idx]))) + '.jpg', 95); Bmp.Resize(ThumbWidth, ThumbHeight); Bmp.SaveToJpeg(ScriptPath + 'output\' + Copy(Files[idx], 1, Length(Files[idx]) - Length(ExtractFileExt(Files[idx]))) + '-thumb.jpg', 95); finally Bmp.Free; end; Status(IntToStr(Idx + 1) + '/' + IntToStr(Len)); end; Status('Done'); end.[/scar] Quote Link to comment Share on other sites More sharing options...