refactor(resize): extract

This commit is contained in:
Tomas Aparicio 2015-04-06 23:43:30 +02:00
parent d9eac32a9a
commit 3904953399
9 changed files with 246 additions and 173 deletions

View file

@ -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)