Been here before but never really succeeded in accomplishing the task. I'm a total NOB at image handling, not understanding alpha-levels, layers or the sparse collection of ununderstandable words in the help file. This is not my expertise! Bear with me.
My customers scan in Multipage TIFF and are allowed to tinkle with bit depth, and DPI themselves. Sometimes they end up with a scanning above 20 MB that they want to email. I need to catch that situation and offer them to optimize data.
First I find the size of data:
Size := 0;
for i := 0 to ImageEnMView.ImageCount - 1 do
with ImageEnMView.MIO.Params[i] do
Inc(Size,Height*Width*SamplesPerPixel);
AvgSize := Size div ImageEnMView.ImageCount;
if (Size > (OneMB shl 2)) or // larger than 4 MB
(AvgSize > (OneMB shl 1)) or // or averging 2 MB per page
(ImageEnMView.MIO.Params[0].DPIY > 150) then // or just too high DPI
if MessageDlg(format('Data is %d MB. Optimize?',[AvgSize div OneMB]), mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
// Tried several things here
end;
Things I have tried:
ImageEnMView.Proc.ConvertTo(CalcColorsUsed);
ImageEnMView.Proc.ConvertToGray;
ImageEnMView.Proc.ConvertToBWOrdered;
Also tried resampling using this altered copy of ImageEnView.ChangeResolution
var
oldDPI: integer;
newheight: integer;
begin
oldDPI := aOldDPI_Y;
newheight := round(aIEBitmap.Height / oldDPI * aNewDPI_Y);
ImageEnMView.Proc.Resample(-1, newheight, aResampleFilter);
ImageEnMView.Update;
.. nothing works. The files are apparently never changed (don't think IrfanView is showing wrong information). Apart from the obvious reason: I'm a fool at this - can anyone please help me, in terms of:
- Best practice on shrinking data
- Examples
I know there's a lot of demos but when not knowing that resizing actually is called resample and such, I'm pretty lost and need someone pointing in the right direction.