LinuxQuestions.org
Visit the LQ Articles and Editorials section
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, 12:42 PM   #1
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 449

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, 02: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, 02: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, 04:07 PM   #4
jefro
Guru
 
Registered: Mar 2008
Posts: 11,954

Rep: Reputation: 1482Reputation: 1482Reputation: 1482Reputation: 1482Reputation: 1482Reputation: 1482Reputation: 1482Reputation: 1482Reputation: 1482Reputation: 1482
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, 05:11 PM   #5
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 449

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 04:00 AM
MythTV: Black&white static line at top of some channels octetstream Linux - Hardware 2 04-15-2007 01:57 PM
Installed Mepis 3.4_rc3: only allows command line login (black screen) smiley_lauf MEPIS 8 01-29-2006 05:03 PM
Command Line Image Editing fractal_chaos Linux - Software 8 10-03-2005 06:33 PM
View image from command line? Rotwang Linux - General 1 03-22-2004 03:51 AM


All times are GMT -5. The time now is 04:48 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration