How to change the convert command to python code -
i'm using imagemagick image enhancement in project. i'm newbie imagemagick, have started using command line argument package. further processing, need change below command python code.
convert sample.jpg -blur 2x1 -sharpen 0x3 -sharpen 0x3 -quality 100 -morphology erode diamond -auto-orient -enhance -contrast -contrast-stretch 0 -gamma .45455 -unsharp 0.25x0.25+8+0.065 -fuzz 2% output.jpg
i think possible using wand package. possible convert arguments using in above command. appreciated. thanks
you can use os.system()
run terminal commands python.
import os command = 'convert sample.jpg -blur 2x1 -sharpen 0x3 -sharpen 0x3 -quality 100 -morphology erode diamond -auto-orient -enhance -contrast -contrast-stretch 0 -gamma .45455 -unsharp 0.25x0.25+8+0.065 -fuzz 2% output.jpg' os.system(command)
if want use paths dynamically, can use .format()
method:
infile = 'sample.jpg' outfile = 'output.jpg' command = 'convert {} -blur 2x1 -sharpen 0x3 -sharpen 0x3 -quality 100 -morphology erode diamond -auto-orient -enhance -contrast -contrast-stretch 0 -gamma .45455 -unsharp 0.25x0.25+8+0.065 -fuzz 2% {}'.format(infile, outfile) os.system(command)
Comments
Post a Comment