LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-07-2012, 11:42 AM   #1
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 492

Rep: Reputation: 31
Question How can I detect if an image is black and white from the command line?


I want to take a jpeg and some how detect if it's black and white or not. Is there a way to detect the colours used in an image from command line and if those colours are all grey colours or not?
 
Old 12-07-2012, 01:07 PM   #2
Midhato
LQ Newbie
 
Registered: Dec 2011
Posts: 13

Rep: Reputation: Disabled
http://superuser.com/questions/27550...ux-commandline
 
1 members found this post helpful.
Old 12-07-2012, 01:07 PM   #3
Midhato
LQ Newbie
 
Registered: Dec 2011
Posts: 13

Rep: Reputation: Disabled
http://superuser.com/questions/27550...ux-commandline
 
1 members found this post helpful.
Old 12-07-2012, 03:07 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,976

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
That is the best way I think and some options. I'd have gone overboard and peeked into the section of the format to find it's value. File command should do that from mime I suspect.
 
Old 12-07-2012, 04:11 PM   #5
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 492

Original Poster
Rep: Reputation: 31
None of the above helped because the images are colour images... the black and white images just don't use most of the spectrum.

I did figure something out though.

convert black_white_test1.png -colorspace gray black_white_test1-grey.png
compare -metric FUZZ black_white_test1.png black_white_test1-grey.png null 2>&1 3>&1 | awk '{print $1}'

Basically if you get a really low number like 0 it's black and white as nothing changed when it was converted to black and white.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Become a Linux command line black-belt LXer Syndicated Linux News 0 03-08-2009 03:00 AM
MythTV: Black&white static line at top of some channels octetstream Linux - Hardware 2 04-15-2007 12:57 PM
Installed Mepis 3.4_rc3: only allows command line login (black screen) smiley_lauf MEPIS 8 01-29-2006 04:03 PM
Command Line Image Editing fractal_chaos Linux - Software 8 10-03-2005 05:33 PM
View image from command line? Rotwang Linux - General 1 03-22-2004 02:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration