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!
-
- Posts: 55
- Joined: Sun Dec 11, 2011 9:47 am
Re: Need help with the "convert" command
You could try replacing "sunset" with "`date`" (backticks within the quotes).
Re: Need help with the "convert" command
That isn't quite enough because of the quoting.joan wrote:You could try replacing "sunset" with "`date`" (backticks within the quotes).
Use
Code: Select all
convert -pointsize 20 -fill yellow -draw "text 270,460 \"`date`\"" file1.jpg file2.jpg
-
- Posts: 4277
- Joined: Sun Jan 15, 2012 1:11 pm
Re: Need help with the "convert" command
You might want to re-analyze your position.That isn't quite enough because of the quoting.
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)
(One of the best lines I've seen on this board lately)
Re: Need help with the "convert" command
This works
as does this
using the $(comand) format, whch is preferred over backticks now.
Code: Select all
convert -pointsize 20 -fill yellow -draw "text 270,460 '`date`'" file1.jpg file2.jpg
Code: Select all
convert -pointsize 20 -fill yellow -draw "text 270,460 '$(date)'" file1.jpg file2.jpg
-
- Posts: 55
- Joined: Sun Dec 11, 2011 9:47 am
Re: Need help with the "convert" command
Thanks all! I tried the last suggestion and it worked perfectly 

Re: Need help with the "convert" command
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")
I think the reason is the amount of "" used in this line.
Can anyone help me with this?
Regards
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
Can anyone help me with this?
Regards