vips

package
v0.0.0-...-6a72910 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: MIT Imports: 7 Imported by: 0

README

ENV

dev env

brew install vips

export CGO_CFLAGS_ALLOW="-Xpreprocessor"

build Dockerfile
FROM alpine:3.12

RUN apk add --update go gcc g++ git

RUN apk add --update build-base vips-dev
build command

set CGO_ENABLED=1, eg:

GOOS=linux CGO_ENABLED=1 GOARCH=amd64 go build -tags 'bindatafs' -a -o main main.go
deploy Dockerfile
FROM alpine:3.12

RUN apk --update upgrade && \

    apk add ca-certificates && \
    
    apk add tzdata && \
    
    apk add build-base vips-dev && \
    
    rm -rf /var/cache/apk/*

Usage

Setup media library and add below code, then it will compress jpg/png and generate webp for you.

import "github.com/qor/media/handlers/vips"

vips.UseVips(vips.Config{EnableGenerateWebp: true})

you can adjust image quality by config if you want.

type Config struct {
	EnableGenerateWebp bool
	PNGtoWebpQuality   int
	JPEGtoWebpQuality  int
	JPEGQuality        int
	PNGQuality         int
	PNGCompression     int
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EnableGenerateWebp = false
	PNGtoWebpQuality   = 90
	JPEGtoWebpQuality  = 80
	GIFtoWebpQuality   = 85
	JPEGQuality        = 80
	PNGQuality         = 90
	PNGCompression     = 9
)

Functions

func UseVips

func UseVips(cfg Config)

Types

type Config

type Config struct {
	EnableGenerateWebp bool
	PNGtoWebpQuality   int
	JPEGtoWebpQuality  int
	JPEGQuality        int
	PNGQuality         int
	PNGCompression     int
}

Jump to

Keyboard shortcuts

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