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
 Problems with TIFF compression for faxing
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

ioan

USA
15 Posts

Posted - Oct 19 2020 :  15:57:40  Show Profile  Reply
First of all, I don't have a current license for ImageEn, but I'm planning to buy one if I can make it work for what I need. Right now I'm using the trial version, but I have no luck with it.

I have trouble duplicating the compression and everything else for a tiff image used for faxing. This resulting image is sent to an ATA device that converts the image into a raw fax and sends it to the receiving machine.

Attached are two tiff images, one called "good-fax.tiff" this one works fine when sending it to a fax machine for printing. The second one, "needs-conversion.tiff", needs to be converted to match the "good-fax" tiff image.

I tried all the code demos I found in this forum, but the resulting image always prints blank on the fax machine.

So far I used imagemagick for conversion, but even imagemagick has the same problem with the attached tiff.

Any help would be appreciated.

Edit:

Even just loading the "good-fax.tiff" and saving it, without any modifications, makes the tiff appear blank in Irfanview and it prints blank on the fax machine. Here is the code I used to load and save the tiff:


    InImage  := TIETIFFHandler.Create;
    OutImage  := TIETIFFHandler.Create;
    Stream := TMemoryStream.Create;
    Bitmap := TIEBitmap.Create;
    IO     := TImageEnIO.CreateFromBitmap(Bitmap);
    try
      if not InImage.ReadFile(source) or (InImage.GetPagesCount <= 0) then
        raise Exception.Create('Error reading file');

      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('Page load failure (%d)', [i2]);

//        IO.IEBitmap.Resample(FAX_WIDTH, IO.IEBitmap.Height);
//        IO.Params.TIFF_Compression := ioTIFF_G3FAX1D;
//        IO.Params.DpiX := FAX_DPIX;
//        IO.Params.DpiY := FAX_DPIY;
//        IO.Params.BitsPerSample := 1;
//        IO.Params.SamplesPerPixel := 1;
//        IO.Params.TIFF_FillOrder := 1;

//        IO.Params.TIFF_Orientation := 1;

        Stream.Size := 0;
        IO.SaveToStreamTIFF(Stream);
        Stream.Position := 0;
        if not OutImage.InsertPageAsStream(Stream, i2) then
          raise Exception.CreateFmt('Page memory error (%d)', [i2]);
      end;

      try
        OutImage.WriteFile(dest);
      except
        on E: Exception do
          raise Exception.Create('Error saving file.' + E.Message);
      end;
    finally
      InImage.Free;
      OutImage.Free;
      Stream.Free;
      Bitmap.Free;
      IO.Free;
    end;



attach/ioan/20201019155525_tiff_example.zip
54.62 KB

xequte

38616 Posts

Posted - Oct 19 2020 :  18:32:02  Show Profile  Reply
Hi

Before I investigate this, is there a reason you don't use a TIEMultiBitmap? It makes it much easier to create and edit multi-page images:

https://www.imageen.com/help/TIEMultiBitmap.html

You can assign the same compression parameters to all frames using DuplicateCompressionInfo:

https://www.imageen.com/help/TIEMultiBitmap.DuplicateCompressionInfo.html





Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ioan

USA
15 Posts

Posted - Oct 19 2020 :  19:07:32  Show Profile  Reply
Hi Nigel,

I just tried TIEMultiBitmap and I got the same results. Irfanview shows the page blank and the fax machine prints it blank, but windows built in viewer shows the tiff fine.

I tried with and without changing the compression, tried with resample and without - same results.



    Bitmap := TIEMultiBitmap.Create;
    Bitmap.ParamsEnabled := True;
    Bitmap.Read(source);
//    Bitmap.Params[0].TIFF_Compression := ioTIFF_G3FAX1D;
//    Bitmap.Resample(0 ,FAX_WIDTH, Bitmap.ImageHeight[0], rfFastLinear);
//    Bitmap.DuplicateCompressionInfo;
    Bitmap.Write(dest);
    Bitmap.Free;
Go to Top of Page

xequte

38616 Posts

Posted - Oct 19 2020 :  23:17:24  Show Profile  Reply
Hi

Please attach your source images so I can test it here.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ioan

USA
15 Posts

Posted - Oct 20 2020 :  00:07:54  Show Profile  Reply
Attached are two tiff images, one called "good-fax.tiff" this one works fine when sending it to a fax machine for printing. The second one, "needs-conversion.tiff", needs to be converted to match the "good-fax" tiff image.

attach/ioan/202010200720_tiff_example.zip
54.62 KB
Go to Top of Page

xequte

38616 Posts

Posted - Oct 20 2020 :  20:17:14  Show Profile  Reply
I'm afraid I can't see any difference between the two formats that I believe should make a difference. Are you able to get any further information from the fax manufacturer?



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ioan

USA
15 Posts

Posted - Oct 21 2020 :  13:32:06  Show Profile  Reply
Any fax machine from any manufacturer will work the same with those images, as far as I know. We have on our network tens of thousands of fax machines and none, that I know, will work well with the image called "needs-conversion.tiff", doesn't matter how I change it with imageen.

One problem I see is that even the image that already works, the one called "good-fax.tiff" in the zip archive, if I open it with imageen and then save it, with no modifications to the compression or anything else, it won't work anymore. Even Irfanview will show a blank page.

Not sure if it makes any difference, I don't know enough about tiff file format, but here is what I get when I just open a "good" tiff file and save it with imageen:

Go to Top of Page

xequte

38616 Posts

Posted - Oct 26 2020 :  15:32:10  Show Profile  Reply
Hi

We have a fix that should resolve the issue. You can email me for the source.

Updated conversions:

attach/xequte/202010261606_G3FAX1D.zip
10.06 KB


Nigel
Xequte Software
www.imageen.com


Go to Top of Page

ioan

USA
15 Posts

Posted - Oct 27 2020 :  11:52:04  Show Profile  Reply
I'll try the new version today and let you know how it goes.
Go to Top of Page

ioan

USA
15 Posts

Posted - Oct 27 2020 :  12:37:38  Show Profile  Reply
Only 1D codding is supported, so only OUT2 was accepted by the test fax machine, but it still printed blank.

Please resize the width of the image to 1728 while keeping the height the same, save it compressed G3 1D and I will try again.
Go to Top of Page

xequte

38616 Posts

Posted - Oct 27 2020 :  15:41:20  Show Profile  Reply
Hi

The version with this fix has not been released yet.

Here is a 1728 wide conversion:

attach/xequte/2020102715410_needs-conversion--OUT3.tiff

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ioan

USA
15 Posts

Posted - Oct 27 2020 :  15:45:15  Show Profile  Reply
YES! This worked. Thank you so much for taking the time to fix it!
Please let me know when you release the fixes and have them in the trial so I can test it in my code.
Go to Top of Page

ioan

USA
15 Posts

Posted - Oct 27 2020 :  17:19:59  Show Profile  Reply
We went ahead and purchased a new license because the trial I'm using solves some other unrelated problems we had.

Thanks again!
Go to Top of Page

xequte

38616 Posts

Posted - Oct 27 2020 :  18:06:39  Show Profile  Reply
Thank you, but please also email me to get the updated source fixing the TIFF issue (it will be officially released with v9.2.6).

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ioan

USA
15 Posts

Posted - Oct 27 2020 :  19:45:58  Show Profile  Reply
Is this the most efficient way of changing the size and compression for a multi page tiff?


    Bitmap := TIEMultiBitmap.Create;
    try
      Bitmap.ParamsEnabled := True;
      Bitmap.Read(OpenPictureDialog1.FileName);
      Bitmap.Params[0].TIFF_Compression := ioTIFF_G3FAX1D;
      Bitmap.ResampleAll(FAX_WIDTH, Bitmap.ImageHeight[0]);
      Bitmap.DuplicateCompressionInfo;
      Bitmap.Write(OpenPictureDialog1.FileName + '-new.tiff');
    finally
      Bitmap.Free;
    end;
Go to Top of Page

xequte

38616 Posts

Posted - Oct 28 2020 :  00:13:53  Show Profile  Reply
Yes, I don't think you can optimize that any further.

Note: You haven't specified a quality filter for ResampleAll, so the quality may be lacking. Although it will slow down the conversion, you might try the various quality filters to see which one suits you best:

https://www.imageen.com/help/TIEMultiBitmap.ResampleAll.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ioan

USA
15 Posts

Posted - Oct 28 2020 :  14:36:10  Show Profile  Reply
Will this code ensure that all frames in a mutipage tiff will have the same parameters?


    tiff := TIEMultiBitmap.Create;
    try
      tiff.ParamsEnabled := True;
      tiff.Read(OpenPictureDialog1.FileName);

      tiff.Params[0].TIFF_Compression := ioTIFF_G3FAX1D;
      tiff.Params[0].BitsPerSample := 1;
      tiff.Params[0].SamplesPerPixel := 1;

      if tiff.ImageWidth[0] <> FAX_WIDTH then
        tiff.ResampleAll(FAX_WIDTH, tiff.ImageHeight[0], TResampleFilter.rfProjectBW);
      tiff.DuplicateCompressionInfo;
      tiff.Write(OpenPictureDialog1.FileName + '-new.tiff');
    finally
      tiff.Free;
    end;

Go to Top of Page

xequte

38616 Posts

Posted - Oct 28 2020 :  22:34:12  Show Profile  Reply
Yes, DuplicateCompressionInfo sets the following properties:

// General
BitsPerSample
SamplesPerPixel

// TIFF
TIFF_Compression
TIFF_PhotometInterpret
TIFF_PlanarConf
TIFF_Orientation
TIFF_LZWDecompFunc
TIFF_LZWCompFunc
TIFF_EnableAdjustOrientation
TIFF_JPEGQuality
TIFF_JPEGColorSpace
TIFF_FillOrder
TIFF_ZIPCompression
TIFF_StripCount
TIFF_Normalize32fImages

// GIF
GIF_Interlaced
GIF_LZWDecompFunc
GIF_LZWCompFunc

// JPEG
JPEG_ColorSpace
JPEG_Quality
JPEG_DCTMethod
JPEG_CromaSubsampling
JPEG_OptimalHuffman
JPEG_Smooth
JPEG_Progressive

// JPEG2000
J2000_ColorSpace
J2000_Rate
J2000_ScalableBy
J2000_SubSamplingH
J2000_SubSamplingV
J2000_Reduce
J2000_Quality

// PCX
PCX_Version
PCX_Compression

// BMP
BMP_Version
BMP_Compression
BMP_HandleTransparency

// ICO
ICO_Format

// PNG
PNG_Interlaced
PNG_Filter
PNG_Compression

// TGA
TGA_Compressed
TGA_GrayLevel

// PS
PS_Compression

// PDF
PDF_Compression

// DICOM
DICOM_Range
DICOM_Compression
DICOM_JPEGQuality
DICOM_J2000Rate

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