Storehouse.Analyzer.EditMetadata (Storehouse v0.2.0)

Copy Markdown View Source

A step (Storehouse.Analyzer) that edits the metadata inside a stored file without re-encoding it, and writes the edited file back over the original, under "edit_metadata".

It does nothing unless asked: an app adds it to its steps, with what to change.

# Where photos were taken, removed before they are shown.
Storehouse.analyze(file, [{Storehouse.Analyzer.EditMetadata, strip: :gps}])

# Only a few tags kept, and the author's name written in.
Storehouse.analyze(file, [
  {Storehouse.Analyzer.EditMetadata,
   strip: {:keep, [:orientation, :copyright]},
   put: %{artist: "Ana Sousa", copyright: "© Ana Sousa"}}
])

Options:

With neither change, or for a type the editor does not edit, the step is :skipped and the file left as it is. A file the editor cannot read fails the step, with why, and the stored file is left as it was.

Its result: "changed", whether the file was rewritten; and when it was, its "bytes" and "checksum" now, and what was done ("stripped", "put"). The steps after it read the edited file.

Checksums

The file's :checksum stays the one of the file as it was uploaded, which is what :existing compares to find the same upload again (Storehouse.store/2): an upload of the same photo still finds it. The checksum of what is stored now is the step's "checksum", and Storehouse.checksum/1 gives it of a copy.