jpg2go

package module
v0.0.0-...-aa23d93 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2017 License: MIT Imports: 1 Imported by: 0

README

jpg2go

A very easy tool for resizing jpg files.

Program logic

Target of this small project should be to practice the decoupling William Kennedy is talking about in his great talk.

Therefore all the logic for resizing a list of pictures is moved into several interfaces.

  • FilePahtsGetter: Gets the filepaths, when a root is given
  • Imager: Returns an image.Image, when a filepath is given
  • Resizer: Resizes the image
  • Writer: Writes the image to a destination

All interfaces are bundled into the type FilesComponents.

The resize package just uses that interface to resize all the given files.

The file cmd/cli/main.go brings all the impementations and the resize package together.

  • osfiles - FilePathsGetter
  • jpg - Imager and Writer
  • nfntresizer - Resizer

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilePathsGetter

type FilePathsGetter interface {
	Get(root string) []string
}

FilePathsGetter takes a filepath and returns filenpaths in a slice

type FilesComponents

type FilesComponents struct {
	FilePathsGetter
	Imager
	Resizer
	Writer
}

FilesComponents are all the interfaces wich are needed for resizing files

type Imager

type Imager interface {
	Image(filePath string) (image.Image, error)
}

Imager takes a filePath and returns an Image

type Resizer

type Resizer interface {
	Resize(img image.Image, s Size) (image.Image, error)
}

Resizer reads resizes and writes an image.

type Size

type Size struct {
	Width  int
	Height int
}

Size describes the size of an image in pixel

type Writer

type Writer interface {
	Write(img image.Image, srcPath string) error
}

Writer takes an Image and the srcPath and writes

Directories

Path Synopsis
cmd
cli command
Package jpg implements the jpg2go Imager interface by using the jpg package from the standart lilbrary
Package jpg implements the jpg2go Imager interface by using the jpg package from the standart lilbrary
Package nfntresizer implements the Resizer by using the Resizer package from nfnt
Package nfntresizer implements the Resizer by using the Resizer package from nfnt
Package osfiles is an implementation for the FilePathGetter and the Writer interface.
Package osfiles is an implementation for the FilePathGetter and the Writer interface.
Package resize uses the jpg2go interfaces to resize alle the pictures
Package resize uses the jpg2go interfaces to resize alle the pictures

Jump to

Keyboard shortcuts

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