Skip to content

Commit

Permalink
fix(vips): fix label filter for grayscale images (#424)
Browse files Browse the repository at this point in the history
* fix(vips): fix label filter for grayscale images

* test: update golden files
  • Loading branch information
cshum authored Mar 27, 2024
1 parent 912f5c5 commit 42a08aa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion vips/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,11 @@ func label(_ context.Context, img *Image, _ imagor.LoadFunc, args ...string) (er
font = args[6]
}
}
// make sure band equals 4
if img.Bands() < 3 {
if err = img.ToColorSpace(InterpretationSRGB); err != nil {
return
}
}
if err = img.AddAlpha(); err != nil {
return
}
Expand Down
1 change: 1 addition & 0 deletions vips/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func TestProcessor(t *testing.T) {
{name: "label float", path: "fit-in/300x200/10x10/filters:fill(yellow):label(IMAGOR,-0.15,0.1,30,red,30)/gopher-front.png", arm64Golden: true},
{name: "label animated", path: "fit-in/150x200/10x00:10x50/filters:fill(yellow):label(IMAGOR,center,-30,25,black)/dancing-banana.gif", arm64Golden: true},
{name: "label animated with font", path: "fit-in/150x200/10x00:10x50/filters:fill(cyan):label(IMAGOR,center,-30,25,white,0,monospace)/dancing-banana.gif", arm64Golden: true},
{name: "label grayscale", path: "fit-in/filters:label(imagor,-1,0,50)/2bands.png", checkTypeOnly: true},
{name: "strip exif", path: "filters:strip_exif()/Canon_40D.jpg"},
{name: "bmp 24bit", path: "100x100/bmp_24.bmp"},
{name: "bmp 8bit", path: "100x100/lena_gray.bmp"},
Expand Down

0 comments on commit 42a08aa

Please sign in to comment.