I am wanting to get the average brightness of a file in python. Having read a previous question [Problem getting terminal output from ImageMagick's compare.exe ( Either by pipe or Python ) I have come up with :
cmd='/usr/bin/convert {} -format "%[fx:100*image.mean]\n" info: > bright.txt'.format(full)
subprocess.call(cmd,shell=True)
with open('bright.txt', 'r') as myfile:
x=myfile.read().replace('\n', '')
return x
the previous question recommended the use of 'pythonmagick' which I can find but with no current documentation and very little recent activity. I could not work out the syntax to use it.
I know that my code is unsatisfactory but it does work. Is there a better way which does not need 'shell=true' or additional file processing ?