Metadata-Version: 2.4
Name: ibatch
Version: 0.6.0
Summary: 
Author: David Polák
Author-email: David Polák <email@davidpolak.cz>
License-Expression: GPL-3.0-or-later
License-File: LICENSE
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: click>=8.3.1
Requires-Dist: geopy>=2.4.1
Requires-Dist: pyexiftool>=0.5.6
Requires-Dist: timezonefinder>=9.0.0
Requires-Python: >=3.13, <4
Description-Content-Type: text/markdown

# ibatch
Does things to photos

## Timestamps

`ibatch timestamp DIR` sets each file's modification time to the moment it was
shot. For photos the exact moment is worked out in this order:

1. an offset embedded in the date (XMP, e.g. `2024:07:01 07:54:26-05:00`);
2. the EXIF offset tag belonging to the date: `OffsetTimeOriginal` for
   `DateTimeOriginal`, `OffsetTimeDigitized` for `CreateDate`; `OffsetTime`
   only if `ModifyDate` equals the capture time (otherwise it describes an
   edit);
3. the offset implied by the GPS time: the capture wall clock minus the GPS
   UTC time, rounded to 15 minutes. It is used only if the rounding leaves less
   than 2 minutes over, and if it is within 3 hours of the longitude's solar
   time (longitude / 15), which rules out most stale GPS fixes;
4. otherwise the machine's timezone is assumed. The command ends with a note
   counting such photos.

`rename` always uses the wall-clock time as shot, whatever the timezone.
`--dry-run` previews the result, including the offset that was used.

Limits of the GPS step: it cannot tell a fresh fix from an old one, as long as
the result looks like a real offset near the photo's longitude. A fix taken an
hour before a photo in Prague gives `+03:00` instead of `+02:00`, silently, and
near the date line a fix a day old can be a whole day off. Prefer the offset
tags; the GPS step is a best effort.

### Videos

QuickTime/MP4 dates are UTC by spec, so a video's moment is known exactly. The
date is the first of `CreateDate`, `MediaCreateDate`, `TrackCreateDate` that
holds one, and the file's own modification time is never used. A video with none
is skipped with a warning. Only the wall clock in the name depends on a zone,
which is found in this order:

1. Apple's `Keys:CreationDate`, if present, is a local time with its offset; it
   is used as it stands (the offset also gives the moment). Without an offset
   its wall clock is kept and read in the machine's timezone;
2. `Keys:AndroidTimeZone`;
3. the GPS position (`Composite:GPSLatitude`/`GPSLongitude`, e.g. from
   `GPSCoordinates`), looked up in a time zone map, with daylight saving time
   as it was on that date. Unlike for photos there is no wall clock to check the
   position against, so a wrong position gives a wrong zone;
4. otherwise the machine's timezone is assumed. The command ends with a note
   counting such videos.

The modification time is the moment itself, so it does not depend on the
machine's timezone (except for a `Keys:CreationDate` without an offset); the
names of videos that reach the last step do.

### Files that fail

A photo or video that cannot be read, or a file that cannot be touched or renamed, is
reported and the rest are still processed. `timestamp` and `rename` then exit
with an error and count it as failed (`--dry-run` too, for an unreadable
photo or video). `geo` only warns about an unreadable photo and leaves it out.
