photosorter

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScanDir added in v1.0.0

func ScanDir(src string) (*[]string, error)

ScanDir scans the specified directory and returns a slice of strings containing the paths of all files in the directory and its subdirectories. It also checks if the directory exist.

Types

type DirSortReport added in v1.0.0

type DirSortReport struct {
	// number of images processed.
	Imgs int
	// map of unprocessed files and the error message.
	Unprocessed map[string]string
}

DirSortReport holds information about the sort directory proccess

func NewDirSortReport added in v1.0.0

func NewDirSortReport() *DirSortReport

NewDirSortReport creates a new DirSortReport with default values.

func SortDir

func SortDir(src string, dst string, format string) (*DirSortReport, error)

SortDir sorts the files in the specified source directory and saves them to the destination directory.

Only files with the .jpg extension will be processed. The function returns a report with the elapsed time, number of images processed, and a map of unprocessed files and the error message.

type Image

type Image struct {
	// contains filtered or unexported fields
}

Image represents an image file and holds original creation time from metadata.

func NewImage

func NewImage(src string) (*Image, error)

NewImage reads the content of an image file from the file system, extracts the EXIF metadata from the file, parses the EXIF metadata to extract the original creation time of the image, and then returns an *Image struct containing the image data, file path, and original creation time.

Returns an error if any of the steps in this process fail, such as if the file cannot be read, if the EXIF metadata cannot be extracted or parsed, or if the original creation time cannot be extracted from the EXIF metadata.

func (*Image) Save

func (img *Image) Save(dir string, format string) error

Save writes the image data to the specified destination directory.

It uses the dst function to generate the file path for the image in the destination directory, and then writes the image data to that file. If the file cannot be written, it returns an error.

Jump to

Keyboard shortcuts

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