Socket
Socket
Sign inDemoInstall

github.com/sfomuseum/go-whosonfirst-media

Package Overview
Dependencies
57
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/sfomuseum/go-whosonfirst-media

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.


Version published

Readme

Source

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

FAQs

Last updated on 06 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc