FreakHavoc
Posts: 55
Joined: Sun Dec 11, 2011 9:47 am

Need help with the "convert" command

Sat Aug 24, 2013 12:48 pm

Hey all, I'm trying to add the current date onto my webcam images (and save them as a new image).

The following command works:

convert -pointsize 20 -fill yellow -draw 'text 270,460 "Sunset"' 1.jpg 1b.jpg

It takes the file 1.jpg, adds the text "Sunset" to it and saves it as 1b.jpg.

Can anyone help me change the above line so that it adds the current date and time instead of "Sunset"?

Thanks a lot in advance!

User avatar
joan
Posts: 16112
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Need help with the "convert" command

Sat Aug 24, 2013 1:09 pm

You could try replacing "sunset" with "`date`" (backticks within the quotes).

User avatar
joan
Posts: 16112
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Need help with the "convert" command

Sat Aug 24, 2013 1:17 pm

joan wrote:You could try replacing "sunset" with "`date`" (backticks within the quotes).
That isn't quite enough because of the quoting.

Use

Code: Select all

convert -pointsize 20 -fill yellow -draw "text 270,460 \"`date`\"" file1.jpg file2.jpg

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Need help with the "convert" command

Sat Aug 24, 2013 1:21 pm

That isn't quite enough because of the quoting.
You might want to re-analyze your position.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
rpdom
Posts: 21174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Need help with the "convert" command

Sat Aug 24, 2013 2:52 pm

This works

Code: Select all

convert -pointsize 20 -fill yellow -draw "text 270,460 '`date`'" file1.jpg file2.jpg
as does this

Code: Select all

convert -pointsize 20 -fill yellow -draw "text 270,460 '$(date)'" file1.jpg file2.jpg
using the $(comand) format, whch is preferred over backticks now.

FreakHavoc
Posts: 55
Joined: Sun Dec 11, 2011 9:47 am

Re: Need help with the "convert" command

Sat Aug 24, 2013 4:19 pm

Thanks all! I tried the last suggestion and it worked perfectly :)

mfkfx
Posts: 1
Joined: Sun Dec 20, 2015 12:08 pm

Re: Need help with the "convert" command

Sun Dec 20, 2015 12:12 pm

Hello,

I have a problem combining this with Pythons os.system:

os.system("convert -pointsize 20 -fill yellow -draw "text 270,460 '$(date)'" image_tmp.jpg image.jpg")

Code: Select all

  File "test.py", line 5
    os.system("convert -pointsize 20 -fill yellow -draw "text 270,460 '$(date)'" image_tmp.jpg image.jpg")
                                                            ^
SyntaxError: invalid syntax
I think the reason is the amount of "" used in this line.

Can anyone help me with this?

Regards

Return to “Beginners”