How to count colors of *.tif and *.gif files??

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
pkashrai

How to count colors of *.tif and *.gif files??

Post by pkashrai »

I have problem to count the colors of *.tif and *.gif image format. To count the colors of *.jpg I used the command:

Code: Select all

identify -format %k img.jpg
This works fine for .jpg file format. But I am having problem with *.tif and *.gif file format. I get the number but I think it's not correct coz it is too huge number (larger than the sum of colors of individual .jpg file format). The problem is *.tif or *.gif files contains more than one *.jpg images. Is there any bash command to count the colors of .tif or .gif directly?? Or I need to split them to .jpgs and count seperately for each jpgs!! Any help will be appreciated!! ThanX in advance !!!!

With Regards,
Prakash Rai
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to count colors of *.tif and *.gif files??

Post by anthony »

try adding a newline or space to the format string, otherwise IM appends all the numbers together, making it look like one huge number...

Code: Select all

identify -format '%k\n' animation.gif
You can also add %f for filename and %s for scene number and %n for total number of scenes, to allow you to identify which image the count is for.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
pkashrai

Re: How to count colors of *.tif and *.gif files??

Post by pkashrai »

Thank U for your reply!!
I got what I wanted..It worked for me !!

With Regards,
Prakash Rai
:D :lol:
Post Reply