mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-07 21:48:13 -08:00
Added progressive jpeg functionality.
This commit is contained in:
parent
b6bc20df55
commit
0019d370e9
5 changed files with 8 additions and 2 deletions
|
|
@ -39,6 +39,7 @@ The [install script](https://github.com/lovell/sharp/blob/master/preinstall.sh)
|
|||
- Enlarge
|
||||
- Crop
|
||||
- Rotate (with auto-rotate based on EXIF orientation)
|
||||
- Progressive
|
||||
- Flip (with auto-flip based on EXIF metadata)
|
||||
- Flop
|
||||
- Zoom
|
||||
|
|
@ -159,6 +160,7 @@ options := bimg.Options{
|
|||
Crop: true,
|
||||
Quality: 95,
|
||||
Rotate: 180,
|
||||
Interlace: 1,
|
||||
}
|
||||
|
||||
buffer, err := bimg.Read("image.jpg")
|
||||
|
|
@ -618,6 +620,7 @@ type Options struct {
|
|||
Flip bool
|
||||
Flop bool
|
||||
NoAutoRotate bool
|
||||
Interlace int
|
||||
Rotate Angle
|
||||
Gravity Gravity
|
||||
Watermark Watermark
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ type Options struct {
|
|||
Flip bool
|
||||
Flop bool
|
||||
NoAutoRotate bool
|
||||
Interlace int
|
||||
Rotate Angle
|
||||
Gravity Gravity
|
||||
Watermark Watermark
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|||
Quality: o.Quality,
|
||||
Type: o.Type,
|
||||
Compression: o.Compression,
|
||||
Interlace: o.Interlace,
|
||||
}
|
||||
|
||||
// Finally save as buffer
|
||||
|
|
|
|||
3
vips.go
3
vips.go
|
|
@ -35,6 +35,7 @@ type vipsSaveOptions struct {
|
|||
Quality int
|
||||
Compression int
|
||||
Type ImageType
|
||||
Interlace int
|
||||
}
|
||||
|
||||
type vipsWatermarkOptions struct {
|
||||
|
|
@ -235,7 +236,7 @@ func vipsSave(image *C.struct__VipsImage, o vipsSaveOptions) ([]byte, error) {
|
|||
break
|
||||
default:
|
||||
debug("Save JPEG options: Q: %s", o.Quality)
|
||||
err = C.vips_jpegsave_bridge(image, &ptr, &length, 1, C.int(o.Quality), 0)
|
||||
err = C.vips_jpegsave_bridge(image, &ptr, &length, 1, C.int(o.Quality), C.int(o.Interlace))
|
||||
break
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func TestVipsRead(t *testing.T) {
|
|||
|
||||
func TestVipsSave(t *testing.T) {
|
||||
image, _, _ := vipsRead(readImage("test.jpg"))
|
||||
options := vipsSaveOptions{Quality: 95, Type: JPEG}
|
||||
options := vipsSaveOptions{Quality: 95, Type: JPEG, Interlace: 1}
|
||||
|
||||
buf, err := vipsSave(image, options)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue