Page 1 of 1

EXIF

Posted: Wed Nov 15, 2023 1:52 pm
by pjw
Im trying to help a friend sorting her photos, which are widely spread over
hard disks, external devices, phones, etc. The idea is to use an SBASIC
program on QPC2 to drill down every device's directory structure looking
for image-type files, extracting the date and copying those images on to a
single external device, ordered into folders by year and month.

The dates are key: If the file name contains a viable date then that is
used else, if I can extract the Exif date, then that is used, if neither
can be found, then the file date is used.

Digital photo file naming conventions have changed considerably over the
past 20 or so years so it is quite a challenge, however, for the file sets
Ive been working with I seem to have found satisfactory solutions - except
when it comes to Exif. A lot of the time my Exif date extaction routine
works fine, but too frequently it is defeated by some photos that appear to
follow different specifications.

The fact that the initial standards document is written in Japanenglish,
that various companies have their own subsets of, or parallel, "standards"
- not always published either; that the information of interest to me is
deeply buried in tangled photographic technicalities, and that the
standards have evolved over time, means that I cannot reliably extract this
information (which I know is there because Windows always seems able to
find it!)

Does anyone here have experience of Exif? And could you give me pointers as
to writing a universal Exif date extraction routine?

If I am successful, Id be happy to share my program. The extraction side of
things is largely finished. At present my program only produces log files,
which could be turned into SBASIC or DOS scripts to do the copying, to mark
duplicates (I havent decided how to handle those yet) or to delete the
originals after copying - if desired. I reckon there will be quite some
manual sorting to do once the scraping together is done (scanned files,
photos of photos, duplicate with different meta data, etc), but at least
(copies of) all the photos will be orderly in one place. The next phase would
be maintenance, but that might be a separate program for another time.

Re: EXIF

Posted: Thu Nov 16, 2023 6:44 am
by NormanDunbar
Morning Per,

It seems there are many confusing aspects to the dates and times in the EXIF data. According to https://en.m.wikipedia.org/wiki/Exif at least.

HTH a little.

Cheers,
Norm.

Re: EXIF

Posted: Thu Nov 16, 2023 6:44 pm
by pjw
NormanDunbar wrote: Thu Nov 16, 2023 6:44 am Morning Per,

It seems there are many confusing aspects to the dates and times in the EXIF data. According to https://en.m.wikipedia.org/wiki/Exif at least.

HTH a little.

Cheers,
Norm.
Thanks Norm. Ive been there already. Doesnt give details of how to find the info in a reliable fashion, and documentation that purports to show the detail isnt reliable/complete, at least not what Ive found, as there are other things going on which defeat those methods. I can reliably decode large swathes of "standard" Exif. However, all this is rather technical and possibly off-topic

Actually this was a "pilot question" to see whether anyone out there was familiar with the Exif format(s). Because, if they were, they could possibly help to unravel it. Anyone using PHGTK may have noticed that it cant handle all JPEGs and in some cases some of the commands to return eg the dimensions etc return the wrong results or cause programs trying to access that data to crash. Ive been in touch with the author but after some initial investigations hes gone quiet of late, so Ive been trying to find work-arounds to avoid using those commands on "dodgy" JPEGs.

So if anyone has ideas or is interested to explore this further, let me know. Im stuck for now and will either have to drop the project(s) or find compromises.

Re: EXIF

Posted: Thu Nov 16, 2023 9:00 pm
by M68008
I would use an existing tool. Exiftool is pretty good and it works on most operating systems (except QDOS, until someone ports Perl to it).
As an example of usage, here is a command from a Windows script I wrote in 2010 that copies images from the camera to folders based on date:

Code: Select all

exiftool -r -d E:\Foto\Pictures\%%Y\%%Y_%%m_%%d "-directory<datetimeoriginal" -ext jpg g:\DCIM
Or - if you prefer to do it the hard way and write your own - here is the Exif specification:
https://www.cipa.jp/std/documents/downl ... ion-2023-E
Before you can apply that knowledge, you also need to parse the image file structure to find the Exif block inside it.
 

Re: EXIF

Posted: Sun Nov 19, 2023 6:14 am
by swensont
M68008 wrote:
> I would use an existing tool. Exiftool is pretty good and it works on most operating systems (except QDOS, until someone ports Perl to it).

Perl 4 was ported years ago by Jonathan Hudson. I think he said porting Perl 5 would be much more difficult.

Tim

Re: EXIF

Posted: Tue Nov 28, 2023 12:14 pm
by pjw
M68008 wrote: Thu Nov 16, 2023 9:00 pm I would use an existing tool. Exiftool is pretty good and it works on most operating systems (except QDOS, until someone ports Perl to it).
As an example of usage, here is a command from a Windows script I wrote in 2010 that copies images from the camera to folders based on date:

Code: Select all

exiftool -r -d E:\Foto\Pictures\%%Y\%%Y_%%m_%%d "-directory<datetimeoriginal" -ext jpg g:\DCIM
Or - if you prefer to do it the hard way and write your own - here is the Exif specification:
https://www.cipa.jp/std/documents/downl ... ion-2023-E
Before you can apply that knowledge, you also need to parse the image file structure to find the Exif block inside it.
 
The documentation you point to is a version of what Ive got already, but
the language is English rather than Japlish ;) so thanks for that! I'll
have another go.

I already have a Windoze-specific version of ExifTool. After struggling
with the Exif format I considered trying to use the embedded intelligence
in ExifTool to extract the desired information, but under the control of an
SBASIC program running under QPC2, I but didnt get very far with that for
various reasons.

Anyway, Id like to have the bits Im interested in under my own control. I
have other, additional, uses for it than Ive declared so far..

Thanks again for your input :)