Giter Site home page Giter Site logo

resize's Introduction

Resize

Image resizing for the Go programming language that includes a few interpolation methods.

Installation

$ go get github.com/nfnt/resize

It's that easy!

Usage

Import package with

import "github.com/nfnt/resize"

Resize creates a scaled image with new dimensions (w,h) using the interpolation function interp.

resize.Resize(w int, h int, img image.Image, interp resize.InterpolationFunction) image.Image 

The provided interpolation functions are

Sample usage:

package main

import (
	"github.com/nfnt/resize"
	"image/jpeg"
	"os"
)

func main() {
	// open "test.jpg"
	file, err := os.Open("test.jpg")
	if err != nil {
		return
	}

	// decode jpeg into image.Image
	img, err := jpeg.Decode(file)
	if err != nil {
		return
	}
	file.Close()

	// resize to width 1000 using Lanczos resampling
	m := resize.Resize(1000, -1, img, resize.Lanczos3)

	out, err := os.Create("test_resized.jpg")
	if err != nil {
		return
	}
	defer out.Close()

	// write new image to file
	jpeg.Encode(out, m, nil)
}

License

Copyright (c) 2012 Jan Schlicht [email protected] This software is released unter the ISC license. The license text is at http://www.isc.org/software/license

resize's People

Contributors

liuben avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.