mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-16 02:45:54 -07: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
|
- Enlarge
|
||||||
- Crop
|
- Crop
|
||||||
- Rotate (with auto-rotate based on EXIF orientation)
|
- Rotate (with auto-rotate based on EXIF orientation)
|
||||||
|
- Progressive
|
||||||
- Flip (with auto-flip based on EXIF metadata)
|
- Flip (with auto-flip based on EXIF metadata)
|
||||||
- Flop
|
- Flop
|
||||||
- Zoom
|
- Zoom
|
||||||
|
|
@ -159,6 +160,7 @@ options := bimg.Options{
|
||||||
Crop: true,
|
Crop: true,
|
||||||
Quality: 95,
|
Quality: 95,
|
||||||
Rotate: 180,
|
Rotate: 180,
|
||||||
|
Interlace: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer, err := bimg.Read("image.jpg")
|
buffer, err := bimg.Read("image.jpg")
|
||||||
|
|
@ -618,6 +620,7 @@ type Options struct {
|
||||||
Flip bool
|
Flip bool
|
||||||
Flop bool
|
Flop bool
|
||||||
NoAutoRotate bool
|
NoAutoRotate bool
|
||||||
|
Interlace int
|
||||||
Rotate Angle
|
Rotate Angle
|
||||||
Gravity Gravity
|
Gravity Gravity
|
||||||
Watermark Watermark
|
Watermark Watermark
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ type Options struct {
|
||||||
Flip bool
|
Flip bool
|
||||||
Flop bool
|
Flop bool
|
||||||
NoAutoRotate bool
|
NoAutoRotate bool
|
||||||
|
Interlace int
|
||||||
Rotate Angle
|
Rotate Angle
|
||||||
Gravity Gravity
|
Gravity Gravity
|
||||||
Watermark Watermark
|
Watermark Watermark
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
||||||
Quality: o.Quality,
|
Quality: o.Quality,
|
||||||
Type: o.Type,
|
Type: o.Type,
|
||||||
Compression: o.Compression,
|
Compression: o.Compression,
|
||||||
|
Interlace: o.Interlace,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally save as buffer
|
// Finally save as buffer
|
||||||
|
|
|
||||||
3
vips.go
3
vips.go
|
|
@ -35,6 +35,7 @@ type vipsSaveOptions struct {
|
||||||
Quality int
|
Quality int
|
||||||
Compression int
|
Compression int
|
||||||
Type ImageType
|
Type ImageType
|
||||||
|
Interlace int
|
||||||
}
|
}
|
||||||
|
|
||||||
type vipsWatermarkOptions struct {
|
type vipsWatermarkOptions struct {
|
||||||
|
|
@ -235,7 +236,7 @@ func vipsSave(image *C.struct__VipsImage, o vipsSaveOptions) ([]byte, error) {
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
debug("Save JPEG options: Q: %s", o.Quality)
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func TestVipsRead(t *testing.T) {
|
||||||
|
|
||||||
func TestVipsSave(t *testing.T) {
|
func TestVipsSave(t *testing.T) {
|
||||||
image, _, _ := vipsRead(readImage("test.jpg"))
|
image, _, _ := vipsRead(readImage("test.jpg"))
|
||||||
options := vipsSaveOptions{Quality: 95, Type: JPEG}
|
options := vipsSaveOptions{Quality: 95, Type: JPEG, Interlace: 1}
|
||||||
|
|
||||||
buf, err := vipsSave(image, options)
|
buf, err := vipsSave(image, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue