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
 TIFF BitsPerSample & SamplesPerPixel
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

dwilbourn

Netherlands
12 Posts

Posted - Nov 09 2022 :  07:23:38  Show Profile  Reply
I am generating TIFF files that are to be converted to GeoTIFFs using a separate command line utility (geoticp). This fails with with the TIFF files created with ImageEn, the error is always that the BitsPerSample are incorrect. This value is actually the same as the BitsPerSample in some good TIFFs from other sources, however the SamplesPerPixel are different so I presume that is the actual culprit. I have explicitly set both these parameters before saving the file and set AutoSetBitDepth to false but the saved files always have the same BitsperSample & SamplesPerPixel values.

How can I explicitly set these parameters? Are there any other parameters that would force values for these parameters?

I always get:
BitsPerSample (3 Short): 8, 8, 8
SamplesPerPixel (1 Short): 4

while the good files have:
BitsPerSample (3 Short): 8, 8, 8
SamplesPerPixel (1 Short): 3

The only other obvious difference is the SubFileType parameter which is Page in the good files but Zero in the ImageEn generated files.

xequte

7376 Posts

Posted - Nov 10 2022 :  14:40:20  Show Profile  Reply
Hi

You can set those properties yourself, though they may be changed to make them compatible with the TIFF compression value that you are using.

Generally it is best to enable AutoSetBitDepth and let ImageEn take care of it for you:

https://www.imageen.com/help/TIEGlobalSettings.AutoSetBitDepth.html

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

dwilbourn

Netherlands
12 Posts

Posted - Nov 10 2022 :  18:57:12  Show Profile  Reply
You can set the properties and they affect the image but the TIFF tags are still always reported as:
BitsPerSample 8, 8, 8
SamplesPerPixel 4

You can see this on the simple app I made, I set the BitsPerSample to 4 and SamplesPerPixel to 2 (just random numbers to see what happened). The generated TIFF file is obviously messed up but the TIFF Tag Viewer app reports:
BitsPerSample 8, 8, 8
SamplesPerPixel 4

I tried other random number combos and the image was usually messed up in some way but the tags are always the same.

The command line app I have to send these images to requires the TIFF tag SamplesPerPixel to be 3.


attach/dwilbourn/20221110184850_screen1.jpg
Go to Top of Page

xequte

7376 Posts

Posted - Nov 13 2022 :  21:31:42  Show Profile  Reply
Hi

Your source PNG has an alpha channel, so if you don't remove that then you will get 4 samples per pixel.

This works in my testing:

  ImageEnView1.IO.LoadFromFileAuto('d:\alpha.png');
  ImageEnView1.IEBitmap.RemoveAlphaChannel(True);
  ImageEnView1.IO.Params.TIFF_Compression := ioTIFF_Uncompressed;
  ImageEnView1.IO.Params.TIFF_PhotometInterpret := ioTIFF_RGB;
  ImageEnView1.IO.Params.BitsPerSample := 8;
  ImageEnView1.IO.Params.SamplesPerPixel := 3;
  ImageEnView1.IO.SaveToFile('d:\out.tiff');


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