goepeg

package module
v0.0.0-...-284e600 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 3 Imported by: 1

README

goepeg

Go wrapper for epeg.

Epeg is a C library for insanely fast JPEG/JPG thumbnail scaling with the minimum fuss and CPU overhead. It makes use of libjpeg features of being able to load an image by only decoding the DCT coefficients needed to reconstruct an image of the size desired.

The library has bundled archive which are automatically linked. This means that installing libepeg and libjpeg is not necessary.

Current archive files are built from epeg v0.1.0 and libjpeg-turbo 2.1.91.

Install

go get github.com/koofr/goepeg

Testing

go test
Test in Docker
docker run --rm -v $(pwd):/app -w /app golang:1.20.2-bullseye sh -c 'go test'

Update libepeg

git clone https://github.com/koofr/epeg.git
macOS
brew install cmake nasm

cd epeg
mkdir build
cd build
cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.14.6 ..
make install
cp epeg/dist/lib/libepeg.a libepeg_darwin_amd64.a
cp epeg/dist/lib/libjpeg.a libjpeg_darwin_amd64.a
cp epeg/dist/include/Epeg.h Epeg.h
Linux

Docker is needed to build for Ubuntu 16.04 compatibility:

cd epeg
docker build -t epeg .
docker create --name epeg-copy epeg
mkdir out
cd out
docker cp epeg-copy:/epeg/dist/lib/libepeg.a libepeg_linux_amd64.a
docker cp epeg-copy:/epeg/dist/lib/libjpeg.a libjpeg_linux_amd64.a
docker cp epeg-copy:/epeg/dist/include/Epeg.h Epeg.h
docker rm epeg-copy
cp epeg/out/{libepeg_linux_amd64.a,libjpeg_linux_amd64.a,Epeg.h} .

Documentation

Index

Constants

View Source
const (
	TransformNone       TransformType = iota
	TransformFlipH                    = iota
	TransformFlipV                    = iota
	TransformTranspose                = iota
	TransformTransverse               = iota
	TransformRot90                    = iota
	TransformRot180                   = iota
	TransformRot270                   = iota
)

Variables

This section is empty.

Functions

func Thumbnail

func Thumbnail(input string, output string, size int, quality int, scaleType ScaleType) error

func Transform

func Transform(input string, output string, transform TransformType) error

Types

type ScaleType

type ScaleType int
const (
	ScaleTypeFitMax ScaleType = iota
	ScaleTypeFitMin           = iota
)

type TransformType

type TransformType int

Jump to

Keyboard shortcuts

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