media

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2023 License: BSD-3-Clause Imports: 0 Imported by: 0

README

go-whosonfirst-media

Go package for common methods and operations to produce Who's On First (WOF) style GeoJSON Feature documents for media records.

Documentation

Go Reference

Usage

go-whosonfirst-media is a package providing common methods and operations to produce Who's On First (WOF) style GeoJSON Feature documents for media records. Specifically it is designed to provide methods for "gathering" images from gocloud.dev/blob Bucket sources, generating one or more image hashes (for comparison and deduplication purposes), cloning (writing) images to a destination for processing and finally for updating WOF feature records after an image has been processed.

Image processing is not handled by this package. As written it is assumed to be handled by the go-iiif/go-iiif package and its "process image" tools which will produce "reports" that this package will use to update WOF feature records.

Gathering images to process
package main

import (
	"context"
	"encoding/json"
	"flag"
	"fmt"
	"github.com/sfomuseum/go-whosonfirst-media/operations/gather"
	"gocloud.dev/blob"
	_ "gocloud.dev/blob/fileblob"
	_ "image/gif"
	_ "image/jpeg"
	_ "image/png"
)

func main() {

	flag.Parse()

	ctx := context.Background()

	cb := func(rsp *gather.GatherImagesResponse) error {
		enc, _ := json.Marshal(rsp)
		fmt.Println(string(enc))
		return nil
	}

	for _, uri := range flag.Args() {
		bucket, _ := blob.OpenBucket(ctx, uri)
		gather.GatherImages(ctx, bucket, cb)
	}
}

For example:

$> go run -mod vendor cmd/gather/main.go file:///usr/local/images/

{"Path":"20210810_2020_17_37.63444_-122.39280.png","Fingerprint":"d015d7246843a87e86a0e2b75cd89a833148603b","MimeType":"image/png","ImageHashes":[{"Approach":"avg","Hash":"a:7f63f75e7c5cfc6c"},{"Approach":"diff","Hash":"d:d6ce6eacccb839d9"}]}

...and so on

For cloning records, and other common operations, please consult the operations documentation.

See also

Documentation

Overview

package media defines common methods and operations for producing Who's On First (WOF) style GeoJSON Feature documents for media records. Common operations include: Gathering files, cloning files, processing files, rotating files and removing files.

Directories

Path Synopsis
cmd
gather
The gather tool will gather images from one or more sources and emit JSON-encoded gather.GatherImagesResponse data structures to STDOUT.
The gather tool will gather images from one or more sources and emit JSON-encoded gather.GatherImagesResponse data structures to STDOUT.
package media provides common methods for creating and updated media-specific Who's On First records.
package media provides common methods for creating and updated media-specific Who's On First records.
package operations provides methods for common media-related operations.
package operations provides methods for common media-related operations.
clone
package clone provides method move an image and it's corresponding feature to a place where it can be processed.
package clone provides method move an image and it's corresponding feature to a place where it can be processed.
gather
package gather provides methods for compiling (gathering) a list of images to be processed.
package gather provides methods for compiling (gathering) a list of images to be processed.
process
package process provides common methods for processing images and their associated files (for example processing reports).
package process provides common methods for processing images and their associated files (for example processing reports).
remove
package remove provides common methods for removing image files.
package remove provides common methods for removing image files.
rotate
package rotate provides common methods for rotating image files.
package rotate provides common methods for rotating image files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL