Git Product home page Git Product logo

imagescaling's Introduction

imagescaling

imagescaling is a go lib for clip or scaling image. support for jpg/png/bmp/gif 【chaining operations】

imagescaling 是一个go图片 裁剪&缩放&旋转 库。 支持 jpg/png/bmp/gif 格式, 【链式操作】

1.get

go get github/chi-chu/imagescaling

2.Mode Explain

  • CenterClip()  Api example:
      Image text

  • CustomClip(x0, y0, x1, y1 uint)  Api example:
      Image text

  • ProportionScale(p float64)   Api example:
    when p=0.5
      Image text

  • FixScale(height, width uint)   Api example:
    when width=0 height=80
      Image text

  • Rotate(RotateMode)   Api example:
      clockwise   only support 90/180/270 degrees
      Rotate90Degrees Rotate180Degrees Rotate270Degrees

  • ReSet()   Api Desc:
      Recover the image to original data

  • GetExt()   Api Desc:
      Get the file type jpg/png/bmp/gif

3.Usage

import github/chi-chu/imagescaling

func main(){
    imageData, err := os.Open("/your/image/path/filename.jpg")
    if err != nil {
        panic(err)
    }
    defer imageData.Close()
    img, err := imagescaling.New(imageData)
    if err != nil {
        panic(err)
    }
    outPutPath := "/your/output/image/path/filename."+ img.GetExt()
    fd, err := os.OpenFile(outPutPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
    if err != nil {
        panic(err)
    }
    defer fd.Close()
    err = img.CustomClip(100, 23, 400, 300).FixScale(100, 0).Rotate(imagescaling.Rotate90Degrees).Draw(fd)
    if err != nil {
        panic(err)
    }
}

imagescaling's People

Contributors

chi-chu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

2hangchen

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.