Releases: cshum/imagor
v1.3.4
v1.3.3
What's Changed
- fix(vips): fix watermark for 2 band images by @cshum in #259
- fix(imagor): negative dims auto flip for imagorpath.Params by @cshum in #260
- feat(imagor): retry query unescape on invalid path by @cshum in #263
- docs: improve overall documentations by @cshum in #265
- feat(vips): add bands to metadata by @cshum in #267
Full Changelog: v1.3.2...v1.3.3
v1.3.2
Utility Filters
v1.3 introduces utility filters, which do not manipulate images but provide useful utilities to the imagor pipeline:
attachment(filename)
returns attachment in theContent-Disposition
header, and the browser will open a "Save as" dialog withfilename
. Whenfilename
not specified, imagor will get the filename from the image sourceexpire(timestamp)
adds expiration time to the content.timestamp
is the unix milliseconds timestamp, e.g. if content is valid for 30s then timestamp would beDate.now() + 30*1000
in JavaScript.preview()
skips the result storage even if result storage is enabled. Useful for conditional caching
Go Library
v1.3 also makes imagor more convenient to be used as a Go library.
See example below and also examples folder for various ways you can use imagor:
package main
import (
"context"
"github.com/cshum/imagor"
"github.com/cshum/imagor/imagorpath"
"github.com/cshum/imagor/loader/httploader"
"github.com/cshum/imagor/vips"
"io"
"os"
)
func main() {
app := imagor.New(
imagor.WithUnsafe(true),
imagor.WithLoaders(httploader.New()),
imagor.WithProcessors(vips.NewProcessor()),
)
ctx := context.Background()
if err := app.Startup(ctx); err != nil {
panic(err)
}
defer app.Shutdown(ctx)
blob, err := app.Serve(ctx, imagorpath.Params{
Unsafe: true,
Image: "https://raw.githubusercontent.com/cshum/imagor/master/testdata/gopher.png",
Width: 500,
Height: 500,
Smart: true,
Filters: []imagorpath.Filter{
{"fill", "white"},
{"format", "jpg"},
},
})
if err != nil {
panic(err)
}
reader, _, err := blob.NewReader()
if err != nil {
panic(err)
}
defer reader.Close()
file, err := os.Create("gopher.jpg")
if err != nil {
panic(err)
}
defer file.Close()
if _, err := io.Copy(file, reader); err != nil {
panic(err)
}
}
What's Changed
- fix accidental copy paste network blocking flag descriptions by @thomasf in #242
- feat(imagor): expire(timstamp) filter by @cshum in #245
- fix(vips): apply focal filter for default resizing by @cshum in #249
- fix(imagor): fix blob.ReadAll() buf size on error by @cshum in #250
- feat(vips): focal point filter focal(x,y) by @cshum in #251
- feat(imagor): imagor.Serve method by @cshum in #253
- feat(imagor): imagor.ServeBlob by @cshum in #254
- fix(imagor): imagor.Serve ensure path generated by @cshum in #255
Full Changelog: v1.2.4...v1.3.2
v1.2.4
v1.2.3
What's Changed
- fix(imagor): json content type detection by @cshum in #222
- build(deps): golang.org/x/text v0.4.0 by @cshum in #227
- build(deps): bump github.com/aws/aws-sdk-go from 1.44.114 to 1.44.126 by @dependabot in #228
- build(deps): bump github.com/stretchr/testify from 1.8.0 to 1.8.1 by @dependabot in #225
- build(deps): libvips 8.13.3 by @cshum in #230
- feat(awsconfig): different AWS credentials for Loader, Storage, Results Storage by @cshum in #231
- feat(awsconfig): AWS config shared credentials by @cshum in #234
Full Changelog: v1.2.2...v1.2.3
v1.2.2
What's Changed
- feat(imagor): return 404 in case the host is not found in the http loader by @jvahldick in #214
- fix(seekstream): remove unnecessary lock from seekstream by @cshum in #216
- refactor(imagor): add image path to not found error by @cshum in #218
- fix(vips): trim with alpha channel handling by @cshum in #219
- feat(imagor): ETag and Modified headers from result storage by @cshum in #221
New Contributors
- @jvahldick made their first contribution in #214
Full Changelog: v1.2.0...v1.2.2
v1.2.0
Improved Memory Allocation
imagor v1.2.0 improved average memory usage over 30% compare with v1.1.5. This is done by revamping the streaming mechanisms to be more efficient and less memory allocations and copy operations. By doing so imagor introduced 2 reusable Go packages seekstream
and fanoutreader
that incorporated into imagor.Blob
mechanisms:
seekstream
seekstream allows seeking on non-seekable io.ReadCloser
source by buffering read data using memory or temp file.
https://pkg.go.dev/github.com/cshum/imagor/seekstream
import "github.com/cshum/imagor/seekstream"
...
var source io.ReadCloser // non-seekable
var buffer seekstream.Buffer // memory or temp file buffer
...
var rs io.ReadSeekCloser = seekstream.New(source, buffer) // seekable
fanoutreader
fanoutreader allows fanout arbitrary number of reader streams concurrently from one data source with known total size, using channel and memory buffer.
https://github.com/cshum/imagor/tree/master/fanoutreader
import "github.com/cshum/imagor/fanoutreader"
...
// http source with known size via Content-Length header
resp, _ := http.DefaultClient.Get("https://raw.githubusercontent.com/cshum/imagor/master/testdata/gopher.png")
size, _ := strconv.Atoi(resp.Header.Get("Content-Length"))
fanout := fanoutreader.New(resp.Body, size) // create fanout from single reader source
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func(i int) {
reader := fanout.NewReader() // spawn new reader
defer reader.Close()
file, _ := os.Create(fmt.Sprintf("gopher-%d.png", i))
defer file.Close()
_, _ = io.Copy(file, reader) // read concurrently alongside other readers
wg.Done()
}(i)
}
wg.Wait()
What's Changed
- feat(imagor): blob.NewReadSeeker for unknown size or over 100mb by @cshum in #208
- feat(seekstream): unified seek stream package for memory or temp file buffer by @cshum in #210
- build(deps): bump github.com/aws/aws-sdk-go from 1.44.106 to 1.44.114 by @dependabot in #207
- feat(fanout): unified fanout concurrent reader by @cshum in #211
- feat: seekstream and fanoutreader by @cshum in #212
Full Changelog: v1.1.9...v1.2.0
v1.1.9
v1.1.6
What's Changed
- build: go 1.19.2 by @cshum in #193
- fix(vips): check resolution after reload max frames by @cshum in #194
- feat(vips): filter max_frames(n) by @cshum in #195
- fix(imagor): fix unexpected EOF by @cshum in #198
- fix(imagor): fanout buffered read by @cshum in #199
- refactor(imagor): optimize fanout buffer allocation by @cshum in #201
Full Changelog: v1.1.5...v1.1.6