Skip to content

Commit

Permalink
Merge pull request #15 from SijmenHuizenga/exif-option
Browse files Browse the repository at this point in the history
Added option to include exif metadata in pictures
  • Loading branch information
dtylman authored Dec 13, 2020
2 parents df34cc7 + d7f3bd8 commit 29b283f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Usage of ./gitmoo-goog:
Time format used for folder paths based on https://golang.org/pkg/time/#Time.Format (default "2016/Janurary")
-use-file-name
Use file name when uploaded to Google Photos (default off)
-include-exif
Retain EXIF metadata on downloaded images. Location information is not included because Google does not include it. (default off)
-download-throttle
Rate in KB/sec, to limit downloading of items (default off)
-concurrent-downloads
Expand All @@ -87,10 +89,10 @@ Usage of ./gitmoo-goog:
On Linux, running the following is a good practice:

```
$ ./gitmoo-goog -folder archive -logfile gitmoo.log -loop -throttle 45 &
$ ./gitmoo-goog -folder archive -logfile gitmoo.log -use-file-name -include-exif -loop -throttle 45 &
```

This will start the process in background, making an API call every 45 seconds, looping forever on all items and saving them to `{pwd}/archive`.
This will start the process in background, making an API call every 45 seconds, looping forever on all items and saving them to `{pwd}/archive`. All images will be downloaded with a filename and metadata as close to original as Google offers through the api.

Logfile will be saved as `gitmoo.log`.

Expand Down
6 changes: 5 additions & 1 deletion downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ func (d *Downloader) downloadImage(item *LibraryItem, filePath string) error {
if strings.HasPrefix(strings.ToLower(item.MediaItem.MimeType), "video") {
url = item.MediaItem.BaseUrl + "=dv"
} else {
url = fmt.Sprintf("%v=w%v-h%v", item.MediaItem.BaseUrl, item.MediaItem.MediaMetadata.Width, item.MediaItem.MediaMetadata.Height)
if d.Options.IncludeEXIF {
url = fmt.Sprintf("%v=d", item.MediaItem.BaseUrl)
} else {
url = fmt.Sprintf("%v=w%v-h%v", item.MediaItem.BaseUrl, item.MediaItem.MediaMetadata.Width, item.MediaItem.MediaMetadata.Height)
}
}
output, err := os.Create(filePath)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions downloader/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ type Options struct {
FolderFormat string
//UseFileName use file name when uploaded to Google Photos
UseFileName bool
//OriginalFiles retain EXIF metadata on downloaded images. Location information is not included.
IncludeEXIF bool
//MaxItems how many items to download
MaxItems int
//number of items to download on per API call
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func main() {
flag.IntVar(&downloader.Options.Throttle, "throttle", 5, "time, in seconds, to wait between API calls")
flag.StringVar(&downloader.Options.FolderFormat, "folder-format", filepath.Join("2006", "January"), "time format used for folder paths based on https://golang.org/pkg/time/#Time.Format")
flag.BoolVar(&downloader.Options.UseFileName, "use-file-name", false, "use file name when uploaded to Google Photos")
flag.BoolVar(&downloader.Options.IncludeEXIF, "include-exif", false, "retain EXIF metadata on downloaded images. Location information is not included.")
flag.Float64Var(&downloader.Options.DownloadThrottle, "download-throttle", 0, "rate in KB/sec, to limit downloading of items")
flag.IntVar(&downloader.Options.ConcurrentDownloads, "concurrent-downloads", 5, "number of concurrent item downloads")
flag.StringVar(&downloader.Options.CredentialsFile, "credentials-file", "credentials.json", "filepath to where the credentials file can be found")
Expand Down

0 comments on commit 29b283f

Please sign in to comment.