mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-15 10:25:55 -07:00
refactor(resize): extract
This commit is contained in:
parent
d9eac32a9a
commit
3904953399
9 changed files with 246 additions and 173 deletions
27
image.go
27
image.go
|
|
@ -4,7 +4,7 @@ type Image struct {
|
|||
buffer []byte
|
||||
}
|
||||
|
||||
func (i *Image) Resize(width int, height int) ([]byte, error) {
|
||||
func (i *Image) Resize(width, height int) ([]byte, error) {
|
||||
options := Options{
|
||||
Width: width,
|
||||
Height: height,
|
||||
|
|
@ -12,17 +12,17 @@ func (i *Image) Resize(width int, height int) ([]byte, error) {
|
|||
return i.Process(options)
|
||||
}
|
||||
|
||||
func (i *Image) Extract(top int, left int, width int, height int) ([]byte, error) {
|
||||
func (i *Image) Extract(top, left, width, height int) ([]byte, error) {
|
||||
options := Options{
|
||||
Width: width,
|
||||
Height: height,
|
||||
Top: top,
|
||||
Left: left,
|
||||
Top: top,
|
||||
Left: left,
|
||||
AreaWidth: width,
|
||||
AreaHeight: height,
|
||||
}
|
||||
return i.Process(options)
|
||||
}
|
||||
|
||||
func (i *Image) Crop(width int, height int) ([]byte, error) {
|
||||
func (i *Image) Crop(width, height int) ([]byte, error) {
|
||||
options := Options{
|
||||
Width: width,
|
||||
Height: height,
|
||||
|
|
@ -31,14 +31,6 @@ func (i *Image) Crop(width int, height int) ([]byte, error) {
|
|||
return i.Process(options)
|
||||
}
|
||||
|
||||
func (i *Image) Thumbnail(width int, height int) ([]byte, error) {
|
||||
options := Options{
|
||||
Width: width,
|
||||
Height: height,
|
||||
}
|
||||
return i.Process(options)
|
||||
}
|
||||
|
||||
func (i *Image) Rotate(a Angle) ([]byte, error) {
|
||||
options := Options{Rotate: a}
|
||||
return i.Process(options)
|
||||
|
|
@ -49,11 +41,6 @@ func (i *Image) Flip() ([]byte, error) {
|
|||
return i.Process(options)
|
||||
}
|
||||
|
||||
func (i *Image) Flop() ([]byte, error) {
|
||||
options := Options{Flip: HORIZONTAL}
|
||||
return i.Process(options)
|
||||
}
|
||||
|
||||
func (i *Image) Convert(t ImageType) ([]byte, error) {
|
||||
options := Options{Type: t}
|
||||
return i.Process(options)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue