Article 6JD5C Help with bash script using identify from imagemagick

Help with bash script using identify from imagemagick

by
Pedroski
from LinuxQuestions.org on (#6JD5C)
I want to get the number of different colours in each image from a folder with images.

identify will give me the sizes:

Quote:
pedro@pedro-HP:~/Downloads$ identify -format %k /home/pedro/Downloads/what_does_this_say.jpg
34089pedro@pedro-HP:~/Downloads$
The jpg what_does_this_say.jpg has 34089 different colours.

Now I want to save all the image names and sizes in an array, or better, a text file, each image and colour count on a new line.

I don't know how bash reads the files in, that is to say, I don't know which file would be first in a list and how the list is ordered, so an array name:colour count would be best.

I thought I could do this, but it doesn't work:

Quote:
path2files="/home/pedro/Downloads/"
for f in $path2files*.jpg;
do
echo "$f"
size = identify -format %k $f
echo "$size"
done
I get this error for each file: size: invalid option -- 'r'

Quote:
/home/pedro/Downloads/what_does_this_say.jpg
size: invalid option -- 'r'
Usage: size [option(s)] [file(s)]
Displays the sizes of sections inside binary files
If no input file(s) are specified, a.out is assumed
The options are:
-A|-B|-G --format={sysv|berkeley|gnu} Select output style (default is berkeley)
-o|-d|-x --radix={8|10|16} Display numbers in octal, decimal or hex
-t --totals Display the total sizes (Berkeley only)
--common Display total size for *COM* syms
--target=<bfdname> Set the binary file format
@<file> Read options from <file>
-h --help Display this information
-v --version Display the program's version

size: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 pei-i386 pe-x86-64 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big pe-bigobj-x86-64 pe-i386 srec symbolsrec verilog tekhex binary ihex plugin
Any tips please?
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments