0

I had initially written all the image magic commands in linux environment for executing in shell scripts. But now due to some functionality to be added I have to implement it through python. Will the same command be compatible? If not how do I go about it?

#!/bin/sh
for f in `ls *.png`
do
 montage -geometry +0+0 -background skyblue -font /usr/share/fonts/dejavu- lgc/DejaVuLGCSansCondensed-Oblique.ttf -label "$f" $f ./label_added/$f
done

And also the following command :

convert n255_n2.tif -gravity West -splice 0x18 -annotate +0+2 "x parameter" n255_n3.tif

2 Answers 2

1

Well. Basically there is similar solution explained in this thread this thread. You need to launch imagemagick in separate process.

Sign up to request clarification or add additional context in comments.

1 Comment

You can use JMagick library which gives Java bindings or spawn another console process like in python example.
1

Try this:

import glob
import subprocess

for f in glob.glob('*.png'):
    subprocess.call(['montage', '-geometry', '+0+0', 
                     '-background', 'skyblue',
                     '-font',
                     '/usr/share/fonts/dejavu-lgc/DejaVuLGCSansCondensed-Oblique.ttf',
                     '-label',
                     '"%s"' % f,  f, './label_added/%s' % f])

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.