Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
Rob Watson df2557835b | 5 years ago | |
---|---|---|
.. | ||
.gitignore | 5 years ago | |
.travis.yml | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 5 years ago | |
cutter.go | 5 years ago |
A Go library to crop images.
Cutter was initially developped to be able
to crop image resized using github.com/nfnt/resize.
Read the doc on https://godoc.org/github.com/oliamb/cutter
Import package with
import "github.com/oliamb/cutter"
Package cutter provides a function to crop image.
By default, the original image will be cropped at the
given size from the top left corner.
croppedImg, err := cutter.Crop(img, cutter.Config{
Width: 250,
Height: 500,
})
Most of the time, the cropped image will share some memory
with the original, so it should be used read only. You must
ask explicitely for a copy if nedded.
croppedImg, err := cutter.Crop(img, cutter.Config{
Width: 250,
Height: 500,
Options: cutter.Copy,
})
It is possible to specify the top left position:
croppedImg, err := cutter.Crop(img, cutter.Config{
Width: 250,
Height: 500,
Anchor: image.Point{100, 100},
Mode: cutter.TopLeft, // optional, default value
})
The Anchor property can represents the center of the cropped image
instead of the top left corner:
croppedImg, err := cutter.Crop(img, cutter.Config{
Width: 250,
Height: 500,
Mode: cutter.Centered,
})
The default crop use the specified dimension, but it is possible
to use Width and Heigth as a ratio instead. In this case,
the resulting image will be as big as possible to fit the asked ratio
from the anchor position.
croppedImg, err := cutter.Crop(baseImage, cutter.Config{
Width: 4,
Height: 3,
Mode: cutter.Centered,
Options: cutter.Ratio&cutter.Copy, // Copy is useless here
})
This lib only manage crop and won't resize image, but it works great in combination with github.com/nfnt/resize
I'd love to see your contributions to Cutter. If you'd like to hack on it:
If you plan to modify the API, let's disscuss it first.
MIT License, Please see the file called LICENSE.
Test Picture: Gopher picture from Heidi Schuyt, http://www.flickr.com/photos/hschuyt/7674222278/,
© copyright Creative Commons(http://creativecommons.org/licenses/by-nc-sa/2.0/)
Thanks to Urturn(http://www.urturn.com) for the time allocated to develop the library.
本项目是群体化方法与技术的开源实现案例,在基于Gitea的基础上,进一步支持社交化的协同开发、协同学习、协同研究等群体创新实践服务,特别是针对新一代人工智能技术特点,重点支持项目管理、git代码管理、大数据集存储管理与智能计算平台接入。
Go SVG Roff JavaScript Shell other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》