Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
How to check compression of an image using c#

for example if an image in "LZW Compression" then output would be lzw. or if it is in Group 4 Fax Encoding compression then output would be Group4.

I have tried the below code but its not working for me

C#
Bitmap bmp = new Bitmap(img);
int compressionTagIndex = Array.IndexOf(bmp.PropertyIdList, 0x103);
                    PropertyItem compressionTag = bmp.PropertyItems[compressionTagIndex];
                    byte[] com = compressionTag.Value;



I am getting result in compressiontag value but how can i pass that value to check condition.


please help me on this.

thanks
Posted
Updated 5-Apr-15 18:30pm
v3
Comments
Richard MacCutchan 4-Apr-15 7:39am    
You need to add some code to check the return values from your various method calls, rather than just assuming they will find what you are looking for.
SukirtiShetty 4-Apr-15 7:44am    
I am getting results in byte array. but i am unable to get that value pls help me
Sergey Alexandrovich Kryukov 6-Apr-15 1:18am    
"I am unable" is not informative.
—SA
SukirtiShetty 4-Apr-15 7:45am    
its showing results in byte array as com[0]=5 and com[1]=0 in (byte[] com = compressionTag.Value;) but how to pass this value to string

it display results as below numbers
1: no compression
2: CCITT Group 3
3: Facsimile-compatible CCITT Group 3
4: CCITT Group 4 (T.6)
5: LZW


but how can i get only value 5 from byte array.
Please help me on this.
Sergey Alexandrovich Kryukov 6-Apr-15 1:45am    
Not clear what the "passing" problem is.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900