dummy

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

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

Go to latest
Published: Oct 9, 2019 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

tinify-go

Golang client for the Tinify API

Usage

Basic Compressing images

This very simple. Just set your API key, then call with your input filename and output filename. As follows:

package main

import (
	"fmt"
	"github.com/tianhe1986/tinify-go/tinify"
)

func main() {
	var key string = "XXXXXX"
	tinify.SetKey(key)
	
	// optional, set the URL of your proxy server
	// tinify.SetProxy("http://user:pass@192.168.0.1:8080")
	
	// from file
	tinify.FromFile("./1.jpg").ToFile("./test1.jpg")
	
	// from url
	tinify.FromUrl("https://XXXXXX.png").ToFile("./test2.png")
}

Resize

There are 4 ways your image will be resized according to the official document

So you could call Resize with different method name, such as follows:

package main

import (
	"fmt"
	"github.com/tianhe1986/tinify-go/tinify"
)

func main() {
	var key string = "XXXXXX"
	tinify.SetKey(key)
	
	// optional, set the URL of your proxy server
	// tinify.SetProxy("http://user:pass@192.168.0.1:8080")
	
	// scale with width
	tinify.FromFile("./1.jpg").Resize("scale", 200, 0).ToFile("./test1-scale-width.jpg")

	// scale with height
	tinify.FromFile("./1.jpg").Resize("scale", 0, 400).ToFile("./test1-scale-height.jpg")

	// fit
	tinify.FromFile("./1.jpg").Resize("fit", 200, 200).ToFile("./test1-fit.jpg")

	// cover
	tinify.FromFile("./1.jpg").Resize("cover", 300, 300).ToFile("./test1-cover.jpg")

	// thumb
	tinify.FromFile("./1.jpg").Resize("thumb", 250, 250).ToFile("./test1-thumb.jpg")
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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