String manipulation methods for EXIF tags
String manipulation methods for EXIF tags
Hello!
I have a question/request regarding the usage of special EXIF tags in -caption -annotate -format etc. commands.
Is it possible to embed, for example, just the date part of the "%[EXIF:DateTime]" tag or to display it in a custom
format (eg. "dd.mm.yyyy")?
In addition, if we define the problem universally, is there any way to apply manipulation functions upon the strings -
for example, mid, pos, left, right...
Thanks in advance!
I am very impressed of the possibilities of your software and thank you so much for this jewel!
Ivaylo Ivanov
I have a question/request regarding the usage of special EXIF tags in -caption -annotate -format etc. commands.
Is it possible to embed, for example, just the date part of the "%[EXIF:DateTime]" tag or to display it in a custom
format (eg. "dd.mm.yyyy")?
In addition, if we define the problem universally, is there any way to apply manipulation functions upon the strings -
for example, mid, pos, left, right...
Thanks in advance!
I am very impressed of the possibilities of your software and thank you so much for this jewel!
Ivaylo Ivanov
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: String manipulation methods for EXIF tags
No. IM has no string manipulation constructs. that is getting sub-strings from larger stings.
At least not yet, and probably not any time soon.
You will be better of using the wrapping API to do that type of work.
At least not yet, and probably not any time soon.
You will be better of using the wrapping API to do that type of work.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: String manipulation methods for EXIF tags
Thanks,
And how about something like: "%[EXIF:DateTime:dd.mm.yyyy]" which is just for the EXIF tags, not for ANY string constant, if it's so difficult?
Cheers!
And how about something like: "%[EXIF:DateTime:dd.mm.yyyy]" which is just for the EXIF tags, not for ANY string constant, if it's so difficult?
Cheers!
anthony wrote:No. IM has no string manipulation constructs. that is getting sub-strings from larger stings.
At least not yet, and probably not any time soon.
You will be better of using the wrapping API to do that type of work.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: String manipulation methods for EXIF tags
I have never used them, but there are DateTime tags for EXIF. See http://www.imagemagick.org/script/escape.phpAnd how about something like: "%[EXIF:DateTime:dd.mm.yyyy]" which is just for the EXIF tags, not for ANY string constant, if it's so difficult?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: String manipulation methods for EXIF tags
The problem is then IM has to be able to parse a date/time string so that it can reformat it to what you request. that is not simple especially as many programs like jhead lets you put just about anything into that string field!!!! It is very free form.
jhead does has parsers for this tag and is better suited to this task as it will extract it without reading in the image data. IM is a image processor, not a EXIF processor!
jhead does has parsers for this tag and is better suited to this task as it will extract it without reading in the image data. IM is a image processor, not a EXIF processor!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: String manipulation methods for EXIF tags
My question was raised because in my region (Greetings from Bulgaria )
we use dates in format "dd.mm.yyyy" (German like) which is not what this EXIF tag is returning.
No matter of this limitation, I am still so happy with ImageMagick
Thank you, Anthony and congrats for your brilliant work!
we use dates in format "dd.mm.yyyy" (German like) which is not what this EXIF tag is returning.
No matter of this limitation, I am still so happy with ImageMagick
Thank you, Anthony and congrats for your brilliant work!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: String manipulation methods for EXIF tags
I know the feeling we in Australia use a similar style.
The best solution is to use Jhead to modify all the date strings in the image EXIF tags. It does this without decoding the JPEG image data so their is no loss of quality.
The best solution is to use Jhead to modify all the date strings in the image EXIF tags. It does this without decoding the JPEG image data so their is no loss of quality.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: String manipulation methods for EXIF tags
Which one of the jHead options is for midifying DateTime exif tag in the JPG with specifying new format?
I haven't noticed option for writing into JPG a value with custom format.
And something more: jHead operates (lists and modifies) DateTime tag. I need to modify DateTimeOriginal tag,
because it's value is preserved exactly as it was by the time photo was taken. DateTime tag value is modified
by many photo editing programs and doesn't give meaningful info for the photo origin.
Cheers!
I haven't noticed option for writing into JPG a value with custom format.
And something more: jHead operates (lists and modifies) DateTime tag. I need to modify DateTimeOriginal tag,
because it's value is preserved exactly as it was by the time photo was taken. DateTime tag value is modified
by many photo editing programs and doesn't give meaningful info for the photo origin.
Cheers!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: String manipulation methods for EXIF tags
Hmmm... I may be wrong. The date may be stored as some type of number n the EXIF header. which means how the number is to be displayed is up to the program making use of that number.
It may be that IM will need some type of global 'date-format' setting to redefine how dates from the EXIF (as well as file creation and modified dates) should be formated. Or better still IM should get that information from the Internationalization/Locale (I18n) settings of the system on which it is running.
On my linux system the date format was defined in the appropriate /usr/share/i18n/locales/ file. "en_AU" in my case.
Maybe if you define your LC_TIME environment variable it will actually distplay right in both IM and jhead!!!
I am just not sure, try it and report back.
It may be that IM will need some type of global 'date-format' setting to redefine how dates from the EXIF (as well as file creation and modified dates) should be formated. Or better still IM should get that information from the Internationalization/Locale (I18n) settings of the system on which it is running.
On my linux system the date format was defined in the appropriate /usr/share/i18n/locales/ file. "en_AU" in my case.
Maybe if you define your LC_TIME environment variable it will actually distplay right in both IM and jhead!!!
I am just not sure, try it and report back.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: String manipulation methods for EXIF tags
EXIF dates are stored as strings, for example, '2006:10:23 11:04:40'. If it was stored as integer values we would have an opportunity to format the date but as strings we just copy them intact. The EXIF specification says:
The date and time when the original image data was generated. For a DSC the date and time the picture was taken
are recorded. The format is "YYYY:MM:DD HH:MM:SS" with time shown in 24-hour format, and the date and time
separated by one blank character [20.H]. When the date and time are unknown, all the character spaces except
colons (":") may be filled with blank characters, or else the Interoperability field may be filled with blank characters.
The character string length is 20 bytes including NULL for termination. When the field is left blank, it is treated as
unknown.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: String manipulation methods for EXIF tags
Well that makes this very clear.
If you want to label images using your own date format, you will need to extract that date in the API you are using (be it shell, PHP, or some other language), modify it and then make use of it as you like.
Sorry...
If you want to label images using your own date format, you will need to extract that date in the API you are using (be it shell, PHP, or some other language), modify it and then make use of it as you like.
Sorry...
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: String manipulation methods for EXIF tags
Yep, that's a pity...I'll use an external identification program.
Thanks, guys!
All the best!
Thanks, guys!
All the best!
Re: String manipulation methods for EXIF tags
You can modify the date with php( PHP 5 >= 5.1.0) ; as well as displaying the date you could use the variable in the IM code ??
I have not had time to see how this code works fully.
I have not had time to see how this code works fully.
Code: Select all
<?php
exec("identify -format \"%[EXIF:DateTime]\" image.jpg", $a);
// http://www.tutorialspoint.com/php/php_function_date_format.htm
$dateSrc = $a[0];
$dateTime = date_create( $dateSrc);
# Now set a new date using date_format();
date_format( $dateTime, 2000, 12, 12);
echo "New Formatted date is ". $dateTime->format("d-m-Y");
echo "<br />";
?>