Skip to content

Commit 8602e7f

Browse files
authored
fix(vips): fix fill(none) for grayscale image (#422)
* fix(vips): fix fill(none) for grayscale image * test: update golden files
1 parent fe944a0 commit 8602e7f

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed
Loading

vips/filter.go

+5
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ func (v *Processor) fill(ctx context.Context, img *Image, w, h int, pLeft, pTop,
215215
}
216216
}
217217
if isTransparent {
218+
if img.Bands() < 3 {
219+
if err = img.ToColorSpace(InterpretationSRGB); err != nil {
220+
return
221+
}
222+
}
218223
if err = img.AddAlpha(); err != nil {
219224
return
220225
}

vips/processor_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func TestProcessor(t *testing.T) {
125125
{name: "crop-percent stretch top flip", path: "0.006120x0.008993:1.0x1.0/stretch/100x200/filters:brightness(-20):contrast(50):rgb(10,-50,30):fill(black)/gopher.png"},
126126
{name: "padding rotation fill blur grayscale", path: "/fit-in/200x210/20x20/filters:rotate(90):rotate(270):rotate(180):fill(blur):grayscale()/gopher.png"},
127127
{name: "fill round_corner", path: "fit-in/0x210/filters:fill(yellow):round_corner(40,60,green)/gopher.png"},
128+
{name: "grayscale fill none", path: "fit-in/100x100/filters:fill(none)/2bands.png"},
128129
{name: "trim alpha", path: "trim/find_trim_alpha.png"},
129130
{name: "trim with crop", path: "trim:bottom-right/50x50:0x0/find_trim.png"},
130131
{name: "trim right", path: "trim:bottom-right/500x500/filters:strip_exif():upscale():no_upscale()/find_trim.png"},

0 commit comments

Comments
 (0)