ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Saving images to individual files: ImageEnMView
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

mvbobj

USA
14 Posts

Posted - May 07 2015 :  15:03:25  Show Profile  Reply
I have an old legacy document storage and retrieval program that enough people are using that I can't change over to multi-page TIFF files. I'm letting them scan a page or multiple pages of b&w, gray or color and saving them individually to disk with the most optimal compressions possible for b&w, gray and color. Hopefully 1 bit, 4 bit and 8 bit.

I just loaded a 35k sized file in as a test and it saved to 11 meg.

I have the images loaded into an ImageEnMView component, I then loop through the image count and do:

ImageEnMView1.CopyToIEBitmap(index, ImageEnIO1.IEBitmap);

then (from the following code you can probably tell that it has been 6 or 7 years since I worked with this sort of thing)

  if frmMainForm.sSaveResolution = 'BW' then
    begin
      ImageEnIO1.Params.TIFF_Compression := ioTIFF_G4FAX;
      ImageEnIO1.SaveToFileTIFF('c:\PHnd8\Data\bwimage.jpg');
    end;
  if frmMainForm.sSaveResolution = 'GR' then
    begin
      ImageEnIO1.Params.JPEG_ColorSpace := ioJPEG_GRAYLEV;
      ImageEnIO1.Params.JPEG_Quality:=75;
      ImageEnIO1.Params.JPEG_Progressive:=True;
      ImageEnIO1.SaveToFileJpeg('c:\PHnd8\Data\grimage.jpg');
    end;
  if frmMainForm.sSaveResolution = 'CL' then
    begin
      ImageEnIO1.Params.JPEG_ColorSpace := ioJPEG_YCbCr;
      ImageEnIO1.Params.JPEG_Quality:=75;
      ImageEnIO1.Params.JPEG_Progressive:=True;
      ImageEnIO1.SaveToFileJpeg('c:\PHnd8\Data\climage.jpg');
    end;

I just need the 1 bit images in individual nicely compressed tif files, and the gray and color individually in jpg files (hopefully with the gray down to 4 bit or something like that).

Actually, the last time I seriously worked on getting image files nicely compressed was in 1998. Seems a bit more complex now.

Sounds easy enough but everything I see on the forum is a LOT more complex than I ever dealt with.

xequte

38514 Posts

Posted - May 07 2015 :  19:12:45  Show Profile  Reply
Hi

To clarify, in your test, you loaded a multi-page TIFF (35MB) into a TImageEnMView and used the code above to save each page to a file, which came out at 1MB. Correct?

And this was using sSaveResolution of 'BW'?

Please also attach the source file.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

mvbobj

USA
14 Posts

Posted - May 07 2015 :  19:49:37  Show Profile  Reply
Actually, I'm beginning by testing a 1 page document - I'll be testing multipage documents after I get this working.

It's a 1 page TIFF file loaded into an ImageEnMView component.

I then move it to an ImageEnIO component as follows:

ImageEnMView1.CopyToIEBitmap(0, ImageEnIO1.IEBitmap);

then:

ImageEnIO1.Params.TIFF_Compression := ioTIFF_G4FAX;
ImageEnIO1.SaveToFileTIFF('c:\PHnd8\Data\bwimage.tif');

It starts as a 35k file and after saving it's an 11 meg file.

My question really is: How do I scan in (perhaps ADF perhaps flatbed) a single or multi page document and save it to disk as individual files with good or acceptable compression? Can I use an ImageEnMView component and save them after they finished? Or do I need to use an ImageEnView and save them from there?

Images might be b&w or gray or color. I need to know how to do this. Then - I'd like to know how the above code turned a 35k image into 11 meg.
Go to Top of Page

xequte

38514 Posts

Posted - May 07 2015 :  21:53:41  Show Profile  Reply
Hi

You might also copy the params:

ImageEnMView1.CopyToIEBitmap( 0, ImageEnIO1.IEBitmap );
ImageEnIO1.Params.Assign( ImageEnMView1.Params[ 0 ]);

I'd like to see the source image. I cannot see why it should change so markedly. Please tell me what values the source has for:

- TIFF_Compression
- TIFF_JPEGColorSpace
- TIFF_JPEGQuality
- TIFF_ZIPCompression

In answer your questions:

1. The factors that affect the size of a TIFF are its resolution (e.g. DPI when scanning) and those compression properties above.

2. If you are just retrieving an image at a time you can use just a TImageEnIO object and its Acquire methods. If you use a TImageEnMView then you will need to iterate through each of its files and save them as you are doing.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

mvbobj

USA
14 Posts

Posted - May 08 2015 :  08:03:47  Show Profile  Reply
Thanks - the "ImageEnIO1.Params.Assign" line worked.

A followup question: the 2 attached files - both the same image - 1 24 bit color, the other 8 bit gray. Shouldn't there be a greater difference in their file sizes?



Go to Top of Page

xequte

38514 Posts

Posted - May 11 2015 :  00:31:32  Show Profile  Reply
Hi

It would depend on the compression that was used. OTOH, I don't think JPEG compression would be improved by a lower color depth.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: