mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-10 07:50:26 -07:00
parent
58b2be80a5
commit
cc2290cb45
8 changed files with 305 additions and 88 deletions
44
README.md
44
README.md
|
|
@ -1,12 +1,12 @@
|
|||
# bimg [](https://travis-ci.org/h2non/bimg) [](https://github.com/h2non/bimg/releases) [](https://godoc.org/github.com/h2non/bimg) [](https://coveralls.io/r/h2non/bimg?branch=master)
|
||||
|
||||
Small [Go](http://golang.org) library for blazing fast and efficient image processing based on [libvips](https://github.com/jcupitt/libvips) using C bindings. It provides a clean, simple and fluent [API](#examples) in pure Go.
|
||||
Small [Go](http://golang.org) library for blazing fast and efficient image processing based on [libvips](https://github.com/jcupitt/libvips) using C bindings. It provides a clean, simple and fluent [API](https://godoc.org/github.com/h2non/bimg) in pure Go.
|
||||
|
||||
bimg is designed to be a small and efficient library with a generic and useful set of features.
|
||||
It uses internally libvips, which requires a [low memory footprint](http://www.vips.ecs.soton.ac.uk/index.php?title=Speed_and_Memory_Use)
|
||||
and it's typically 4x faster than using the quickest ImageMagick and GraphicsMagick settings or Go native `image` package, and in some cases it's even 8x faster processing JPEG images.
|
||||
|
||||
It can read JPEG, PNG, WEBP and TIFF formats and output to JPEG, PNG and WEBP. It supports common [image transformation](#supported-image-operations) operations such as crop, resize, rotate... and conversion between multiple formats.
|
||||
It can read JPEG, PNG, WEBP and TIFF formats and output to JPEG, PNG and WEBP. It supports common [image transformation](#supported-image-operations) operations such as crop, resize, rotate, zoom, watermark... and conversion between multiple formats.
|
||||
|
||||
For getting started, take a look to the [examples](#examples) and [programmatic API](https://godoc.org/github.com/h2non/bimg) documentation.
|
||||
|
||||
|
|
@ -41,13 +41,14 @@ The [install script](https://github.com/lovell/sharp/blob/master/preinstall.sh)
|
|||
- Resize
|
||||
- Enlarge
|
||||
- Crop
|
||||
- Rotate (and auto-rotate based on EXIF orientation)
|
||||
- Flip (and auto-flip based on EXIF metadata)
|
||||
- Rotate (with auto-rotate based on EXIF orientation)
|
||||
- Flip (with auto-flip based on EXIF metadata)
|
||||
- Flop
|
||||
- Zoom
|
||||
- Thumbnail
|
||||
- Extract area
|
||||
- Format conversion
|
||||
- Watermark (fully customizable text-based)
|
||||
- Format conversion (with additional quality/compression settings)
|
||||
- EXIF metadata (size, alpha channel, profile, orientation...)
|
||||
|
||||
## Performance
|
||||
|
|
@ -165,6 +166,34 @@ if err != nil {
|
|||
bimg.Write("new.jpg", newImage)
|
||||
```
|
||||
|
||||
#### Watermark
|
||||
|
||||
```go
|
||||
buffer, err := bimg.Read("image.jpg")
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
|
||||
options := bimg.Watermark{
|
||||
Watermark{
|
||||
Text: "Chuck Norris - Copyright (c) 2315",
|
||||
Opacity: 0.25,
|
||||
Width: 200,
|
||||
DPI: 100,
|
||||
Margin: 150,
|
||||
Font: "sans bold 12",
|
||||
Background: bimg.Color{255, 255, 255},
|
||||
}
|
||||
}
|
||||
|
||||
newImage, err := bimg.NewImage(buffer).Watermark()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
|
||||
bimg.Write("new.jpg", newImage)
|
||||
```
|
||||
|
||||
#### Fluent interface
|
||||
|
||||
```go
|
||||
|
|
@ -491,7 +520,6 @@ Determines the image type format (jpeg, png, webp or tiff)
|
|||
type Interpolator int
|
||||
```
|
||||
|
||||
|
||||
```go
|
||||
const (
|
||||
BICUBIC Interpolator = iota
|
||||
|
|
@ -531,6 +559,10 @@ type Options struct {
|
|||
}
|
||||
```
|
||||
|
||||
## Special Thanks
|
||||
|
||||
- [John Cupitt](https://github.com/jcupitt)
|
||||
|
||||
## License
|
||||
|
||||
MIT - Tomas Aparicio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue