• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cshum / imagor / 15284632253

27 May 2025 08:05PM UTC coverage: 92.02% (-0.4%) from 92.448%
15284632253

push

github

cshum
BufferFallback

20 of 31 new or added lines in 1 file covered. (64.52%)

19 existing lines in 2 files now uncovered.

4855 of 5276 relevant lines covered (92.02%)

1.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

18.52
/processor/vipsprocessor/bmp.go
1
package vipsprocessor
2

3
import (
4
        "github.com/cshum/imagor"
5
        "github.com/cshum/vipsgen/vips"
6
        "golang.org/x/image/bmp"
7
        "image"
8
        "image/draw"
9
        "io"
10
)
11

UNCOV
12
func loadImageFromBMP(r io.Reader) (*vips.Image, error) {
×
UNCOV
13
        img, err := bmp.Decode(r)
×
UNCOV
14
        if err != nil {
×
15
                return nil, err
×
16
        }
×
UNCOV
17
        rect := img.Bounds()
×
UNCOV
18
        size := rect.Size()
×
UNCOV
19
        rgba, ok := img.(*image.RGBA)
×
UNCOV
20
        if !ok {
×
UNCOV
21
                rgba = image.NewRGBA(rect)
×
UNCOV
22
                draw.Draw(rgba, rect, img, rect.Min, draw.Src)
×
UNCOV
23
        }
×
UNCOV
24
        return vips.NewImageFromMemory(rgba.Pix, size.X, size.Y, 4)
×
25
}
26
func BmpFallbackFunc(blob *imagor.Blob, _ *vips.LoadOptions) (*vips.Image, error) {
1✔
27
        if blob.BlobType() == imagor.BlobTypeBMP {
1✔
UNCOV
28
                // fallback with Go BMP decoder if vips error on BMP
×
UNCOV
29
                r, _, err := blob.NewReader()
×
UNCOV
30
                if err != nil {
×
31
                        return nil, err
×
32
                }
×
UNCOV
33
                defer func() {
×
UNCOV
34
                        _ = r.Close()
×
UNCOV
35
                }()
×
UNCOV
36
                return loadImageFromBMP(r)
×
37
        } else {
1✔
38
                return nil, imagor.ErrUnsupportedFormat
1✔
39
        }
1✔
40
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc