Skip to content

Commit

Permalink
Adds export method
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbyttow committed Mar 16, 2018
1 parent 69bac1c commit 0749978
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/bench/soak/soak.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func soak() {
if err != nil {
panic(err)
}
_, _, err = bg.Export(vips.ExportParams{})
if err != nil {
panic(err)
}
}

if count%batch == 0 {
Expand Down
8 changes: 8 additions & 0 deletions pkg/vips/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ func (ref *ImageRef) Composite(overlay *ImageRef, mode BlendMode) error {
return nil
}

// Export exports the image
func (ref *ImageRef) Export(params ExportParams) ([]byte, ImageType, error) {
if params.Format == ImageTypeUnknown {
params.Format = ref.format
}
return vipsExportBuffer(ref.image, &params)
}

// ToBytes writes the image to memory in VIPs format and returns the raw bytes, useful for storage.
func (ref *ImageRef) ToBytes() ([]byte, error) {
var cSize C.size_t
Expand Down

0 comments on commit 0749978

Please sign in to comment.