|
|
|
@ -42,7 +42,7 @@ The [install script](https://github.com/lovell/sharp/blob/master/preinstall.sh)
|
|
|
|
- Enlarge
|
|
|
|
- Enlarge
|
|
|
|
- Crop
|
|
|
|
- Crop
|
|
|
|
- Rotate
|
|
|
|
- Rotate
|
|
|
|
- Flip
|
|
|
|
- Flip
|
|
|
|
- Thumbnail
|
|
|
|
- Thumbnail
|
|
|
|
- Extract area
|
|
|
|
- Extract area
|
|
|
|
- Format conversion
|
|
|
|
- Format conversion
|
|
|
|
@ -56,7 +56,19 @@ Here you can see some performance test comparisons for multiple scenarios:
|
|
|
|
- [libvips speed and memory usage](http://www.vips.ecs.soton.ac.uk/index.php?title=Speed_and_Memory_Use)
|
|
|
|
- [libvips speed and memory usage](http://www.vips.ecs.soton.ac.uk/index.php?title=Speed_and_Memory_Use)
|
|
|
|
- [sharp performance tests](https://github.com/lovell/sharp#the-task)
|
|
|
|
- [sharp performance tests](https://github.com/lovell/sharp#the-task)
|
|
|
|
|
|
|
|
|
|
|
|
bimg performance tests coming soon!
|
|
|
|
#### bimg performance tests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tested using Go 1.4 and libvips-7.42.3 in OSX i7 2.7Ghz
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
PASS
|
|
|
|
|
|
|
|
BenchmarkResizeLargeJpeg 30 46652408 ns/op
|
|
|
|
|
|
|
|
BenchmarkResizePng 20 57387902 ns/op
|
|
|
|
|
|
|
|
BenchmarkResizeWebP 500 2453220 ns/op
|
|
|
|
|
|
|
|
BenchmarkConvertToJpeg 30 35556414 ns/op
|
|
|
|
|
|
|
|
BenchmarkCrop 30 51768475 ns/op
|
|
|
|
|
|
|
|
BenchmarkExtract 30 50866406 ns/op
|
|
|
|
|
|
|
|
ok 9.424s
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## API
|
|
|
|
## API
|
|
|
|
|
|
|
|
|
|
|
|
@ -193,6 +205,12 @@ func Resize(buf []byte, o Options) ([]byte, error)
|
|
|
|
func Shutdown()
|
|
|
|
func Shutdown()
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### func Write
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
|
|
|
func Write(path string, buf []byte) error
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### type Angle
|
|
|
|
#### type Angle
|
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
```go
|
|
|
|
@ -263,13 +281,13 @@ func (i *Image) Convert(t ImageType) ([]byte, error)
|
|
|
|
#### func (*Image) Crop
|
|
|
|
#### func (*Image) Crop
|
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
```go
|
|
|
|
func (i *Image) Crop(width int, height int) ([]byte, error)
|
|
|
|
func (i *Image) Crop(width, height int) ([]byte, error)
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### func (*Image) Extract
|
|
|
|
#### func (*Image) Extract
|
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
```go
|
|
|
|
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)
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### func (*Image) Flip
|
|
|
|
#### func (*Image) Flip
|
|
|
|
@ -278,12 +296,6 @@ func (i *Image) Extract(top int, left int, width int, height int) ([]byte, error
|
|
|
|
func (i *Image) Flip() ([]byte, error)
|
|
|
|
func (i *Image) Flip() ([]byte, error)
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### func (*Image) Flop
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
|
|
|
func (i *Image) Flop() ([]byte, error)
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### func (*Image) Metadata
|
|
|
|
#### func (*Image) Metadata
|
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
```go
|
|
|
|
@ -299,7 +311,7 @@ func (i *Image) Process(o Options) ([]byte, error)
|
|
|
|
#### func (*Image) Resize
|
|
|
|
#### func (*Image) Resize
|
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
```go
|
|
|
|
func (i *Image) Resize(width int, height int) ([]byte, error)
|
|
|
|
func (i *Image) Resize(width, height int) ([]byte, error)
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### func (*Image) Rotate
|
|
|
|
#### func (*Image) Rotate
|
|
|
|
@ -314,6 +326,12 @@ func (i *Image) Rotate(a Angle) ([]byte, error)
|
|
|
|
func (i *Image) Size() (ImageSize, error)
|
|
|
|
func (i *Image) Size() (ImageSize, error)
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### func (*Image) Thumbnail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
|
|
|
func (i *Image) Thumbnail(pixels int) ([]byte, error)
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### func (*Image) Type
|
|
|
|
#### func (*Image) Type
|
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
```go
|
|
|
|
@ -325,10 +343,11 @@ func (i *Image) Type() string
|
|
|
|
```go
|
|
|
|
```go
|
|
|
|
type ImageMetadata struct {
|
|
|
|
type ImageMetadata struct {
|
|
|
|
Orientation int
|
|
|
|
Orientation int
|
|
|
|
|
|
|
|
Channels int
|
|
|
|
Alpha bool
|
|
|
|
Alpha bool
|
|
|
|
Profile bool
|
|
|
|
Profile bool
|
|
|
|
Space int
|
|
|
|
|
|
|
|
Type string
|
|
|
|
Type string
|
|
|
|
|
|
|
|
Space string
|
|
|
|
Size ImageSize
|
|
|
|
Size ImageSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
```
|
|
|
|
@ -407,6 +426,8 @@ func (i Interpolator) String() string
|
|
|
|
type Options struct {
|
|
|
|
type Options struct {
|
|
|
|
Height int
|
|
|
|
Height int
|
|
|
|
Width int
|
|
|
|
Width int
|
|
|
|
|
|
|
|
AreaHeight int
|
|
|
|
|
|
|
|
AreaWidth int
|
|
|
|
Top int
|
|
|
|
Top int
|
|
|
|
Left int
|
|
|
|
Left int
|
|
|
|
Crop bool
|
|
|
|
Crop bool
|
|
|
|
@ -423,6 +444,7 @@ type Options struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
|
|
MIT - Tomas Aparicio
|
|
|
|
MIT - Tomas Aparicio
|
|
|
|
|