Skip to content
k3b edited this page Aug 26, 2020 · 10 revisions

If you have photos on your pc and on your android device you need some mechanism to keep photos and their properties (geo-latitude/longitude, tags, filepath/names) in sync.

This page describes technical details how this could be done

See also:


Howto sync metadata changes of jpg photos between Android and PC

On android images are files with the extension ".jpg" that are usually stored somewhere below the folders DCIM or PICTURES. The Mediascanner is an android service that automatically scans the file system for media files (image, audio, video) and store the scan results in the android MediaDatabase. Android-Gallery apps use the MediaDatabase to find videos and images.

The android stock mediascanner reads data from

  • the jpg exif segment that contains CreateDate (when photo was taken) and geo location (latitude/longitude)
  • and data from the filesystem (filename with full path, date when the file was last modified)

Since "A Photo Manager" uses the android stock MediaDatabase it can find/sort by path/photo-date/geo without any extra media scan. All work was already done by android stock media scanner.

jpg files can have additional properties (meta data) in the jpg iptc segment which is not supported by android but by "A Photo Manager": tags(keywords), Image-Title, Image-Description, Image-Rating.

Because memory and display is limited on the android device i usually create a scaled down copy of the images on the pc to 1024 x xxx or xxx x 1024 using irfanview batch processing which can be downloaded here. The reduced images contain all Imagefiles with their properties (exif meta data).

If you do not need to transfer the iptc-meta-data (tags(keywords), Image-Title, Image-Description, Image-Rating) to android you are done.

(since version 0.6.1) : Else you have to invoke the "a Photo Manager" build-in media scanner that can also read tags(keywords), Image-Title, Image-Description, Image-Rating form jpg-iptc and/or jpg-exif.

Currently there is no library to read/write iptc-meta-data inside jpg files for android so i "A Photo Manager" can use external sidecar files to store the extended metadata in xmp file format. instead. You can use the apmJpg2xmp.cmd batch to generate one xmp file per jpg file and copy these to android. You need to run "A Photo Manager"-s mediascanner to scan all jpg/xmp files which might take a long time if you need to (re)scan many files. See apmXxxx.cmd below.

You can add all photo properties (extended metadata) into one csv file that "A Photo Manager" can read. This processing is much faster than rescan. The "apm2Csv.cmd" batch can generate this csv file on a pc.

  • Execute apm2Csv.cmd in the pc images rootfolder.

    • Example: execute apm2Csv.cmd in folder C:\Users\MyUserName\Pictures\managedPhotos`
  • Copy the generated file media.csv into the android image rootfolder

    • Example: copy pc file C:\Users\MyUserName\Pictures\managedPhotos\media.csv to android /sdcard/PICTURES/managedPhotos/media.csv
  • On Android open a filemanager and click on the copied media.csv

    • Example: click on /sdcard/PICTURES/managedPhotos/media.csv

    See apmXxxx.cmd below.

With "A Photo Manager" you can set (geo-latitude/longitude, edit tags or change filenames of images (copy/move/rename/delete). This chapter explains how you can get the changes back to the pc.

Since "A Photo Manager Version 0.6.0" all jpg file changes are also applied to the xmp sidecarfile (which is created if necessary). You can copy all newly created or modified xmp files back to pc and apply the apmXmp2jpg.cmd which transfer the content of xmp to the jpg. You can use the xmp-file date to decide which xmp-files to copy. See apmXxxx.cmd below.

A Photo Manager writes a log file /storage/sdcard0/copy/aPhotomanager.log that conantain all file operations on images as call apmXXX.cmd /path/to/file.jpg parameter. There is a sub batch for every possible jpg operation: apmCopy.cmd, apmMove.cmd, apmDelete.cmd, apmGps.cmd, apmTagsRemove.cmd, apmTagsAdd.cmd See apmXxxx.cmd below.

You can

  • copy this log to pc,
  • rename it to aPhotomanager.log.cmd
  • and replace the absolute paths to relative paths that match the image root on pc
  • and execute that batch to apply the changes made on android to the pc files

Since "A Photo Manager Version 0.6.0" all jpg file changes are also logged to an android database "transactionlog" that contain the same infos as /storage/sdcard0/copy/aPhotomanager.log. This info will be used to create Pc app specific sync adapters. If someone wants to implemnt a syncadapter for the pc photomanager digigam the data to be transfered from android to pc could be selected and transfered from this table.

PC software : IrfanView, ExifTool, apmXxxx.cmd, apmXxxx.args

If you want to sync photo properties (meta data) between pc and android you need some pc software that generates data to be transfered to android and to apply changes received from android.

Irfanview is a tool that can downscale images through folder hirachies and preserves the photo properties (exif meta data). It can be downloaded here. My android images are a scaled down version with 1024 x Xxx or Xxx x 1024 resolution which

  • require much less space
  • are faster to display without the need to have memory consuming precalculated miniatur images in gallery view (thumbnails)

I have created some pc batchfiles apmXxxx.cmd for MS Windows to process jpg photo properties (meta data) that can be downloaded from https://github.com/k3b/APhotoManager/blob/master/fotolib2/src/test/resources/de/k3b/media/ .

These batches needs installed commandlinetool ExifTool which can be downloaded here Copy the batches into the ExifTool install dir and make shure that this directory is included in the search path.

  • apmXmp2Jpg.cmd
    • transfers photo properties (meta data) from one xmp sidecar file back to it-s jpg
    • example: apmXmp2Jpg.cmd path/to/file.jpg adds content of path/to/file(.jpg).xmp to file.jpg
    • apmXmp2jpg.args define how xmp meta data are mapped to jpg exif/iptc data
      • must be copied to the same directory as apmXmp2Jpg.cmd
  • apmJpg2xmp.cmd
    • transfers meta data from jpg file to xmp sidecar file. Updates existing or creates new xmp file.
    • example: apmJpg2xmp.cmd path/to/file.jpg updates/creates path/to/file(.jpg).xmp
    • apmJpg2xmp.args define how jpg exif/iptc meta data are mapped to xmp data
      • must be copied to the same directory as apmJpg2xmp.cmd
  • apmGps.cmd
    • set geo location (latitude/longitude) data to jpg/xmp file
    • Example CALL apmGps path/to/file.jpg 53.169414 8.627358 sets geo info to file.jpg and to file(.jpg).xmp (if xmp exists)
  • apm2Csv.cmd generates csv with meta data of all xmp/jpg of current directory and subdirectories. Execute in pc image root directory
  • apmCopy.cmd
    • copy image and corresponding xmp from one directory to an other
    • Example CALL apmCopy path/to/some/file.jpg path/to/otherfile.jpg copy file.jpg and file(.jpg).xmp (if xmp exists) to an other directory
  • apmMove.cmd
    • move image and corresponding xmp from one directory to an other or renames it.
    • Example CALL apmMove path/to/some/file.jpg path/to/other/file.jpg move file.jpg and file(.jpg).xmp (if xmp exists) to an other directory
    • Example CALL apmMove path/to/oldFileName.jpg path/to/newFileName.jpg rename oldFileName.jpg and oldFileName(.jpg).xmp (if xmp exists) to newFileName.*
  • apmDelete.cmd
    • delete image and corresponding xmp
    • Example CALL apmDelete path/to/some/file.jpg deletes file.jpg and file(.jpg).xmp (if xmp exists)
  • apmTagsAdd.cmd
    • add tags(keywords) to jpg and xmp.
    • Example call apmTagsAdd path/to/some/file.jpg "peter" "harbour" adds the tags "peter" and "harbour" to the already existing tags of file.jpg and file(.jpg).xmp (if xmp exists)
  • apmTagsRemove.cmd
    • remove tags(keywords) from jpg and xmp.
    • Example call apmTagsRemove path/to/some/file.jpg "peter" "harbour" removes the tags "peter" and "harbour" to file.jpg and file(.jpg).xmp (if xmp exists)
Clone this wiki locally