Page 1 of 1
Adding time stamp for single file in Windows
Posted: 2014-01-06T14:16:30-07:00
by steahl
Hi,
I have an IP camera creating a jpg-file which is uploaded to my webserver. I want to add a time stamp to the file called image.jpg with the file date and time and save it with another name. The jpg contains no Exif-tags. I want to run the code in a Windows batch file. Can someone help me with this?
Re: Adding time stamp for single file in Windows
Posted: 2014-01-06T14:31:28-07:00
by snibgo
Do you want to modify the image to include the date/time or just change the name? The Windows "for" command can get the date/time of the file. See "help for" and "help rename".
Re: Adding time stamp for single file in Windows
Posted: 2014-01-06T16:03:01-07:00
by fmw42
Alternately, you can put the date/time, etc in the comments field of the verbose information in the meta data of the file. see
http://www.imagemagick.org/script/comma ... hp#comment
Re: Adding time stamp for single file in Windows
Posted: 2014-01-07T06:25:26-07:00
by steahl
Sorry I was unclear in my question. I want to time stamp the no-exif jpg in the same way the code below does for a jpg with exif-information.
convert PICT0001.JPG -font Arial -pointsize 20 -fill yellow -annotate +450+440 "%%[exif:DateTime]" PICT0001_trans.jpg
And I want to do that in a windows batch file, i.e. the double % signs. My line of thought is that I must declare a variable and then assign the "file modified date" to it somehow. And then use this variable as an argument for the annotate option. But my programming skills is not up for the job

Re: Adding time stamp for single file in Windows
Posted: 2014-01-07T12:06:44-07:00
by fmw42
If the file already has the DateTime stamp in the EXIF meta data, then your command should work. If you are trying to add the Date/Time to the exif meta data, ImageMagick does not do that.
If you can look up the Data/Time on the system and put it into a variable, then you can use your command with the variable as follows.
date_time=$(date)
convert PICT0001.JPG -font Arial -pointsize 20 -fill yellow -annotate +450+440 "$date_time" PICT0001_trans.jpg
The above would be unix syntax. One of the Windows users would have to explain the syntax and how to get the data/time from the Windows OS
Re: Adding time stamp for single file in Windows
Posted: 2014-01-07T12:48:40-07:00
by snibgo
@steahl: Did you type "help for" as I suggested?
Code: Select all
for %%A in (*.png) do (
set FNAME=%%A
set FDATE=%%~tA
convert ...
)
Re: Adding time stamp for single file in Windows
Posted: 2014-01-08T13:42:09-07:00
by steahl
Thanks for your help. I managed to get what I wanted with this code:
Code: Select all
for %%A in (image.jpg) do set FDATE=%%~tA
convert image.jpg -pointsize 20 -fill yellow -gravity southeast ^ -annotate +10+10 "%FDATE%" image_trans.jpg
Re: Adding time stamp for single file in Windows
Posted: 2014-01-08T13:56:46-07:00
by fmw42
steahl wrote:
Code: Select all
for %%A in (image.jpg) do set FDATE=%%~tA
convert image.jpg -pointsize 20 -fill yellow -gravity southeast ^ -annotate +10+10 "%FDATE%" image_trans.jpg
Everything after ^ should be on a separate line. The ^ is the new line indicator and there should be nothing following it, not even a space. So it should properly be
Code: Select all
for %%A in (image.jpg) do set FDATE=%%~tA
convert image.jpg -pointsize 20 -fill yellow -gravity southeast ^
-annotate +10+10 "%FDATE%" image_trans.jpg
If you want it all on one line, then remove the ^
Code: Select all
for %%A in (image.jpg) do set FDATE=%%~tA
convert image.jpg -pointsize 20 -fill yellow -gravity southeast -annotate +10+10 "%FDATE%" image_trans.jpg