Add Image.Length()

Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
master
Yoan Blanc 9 years ago
parent 75a5d927d3
commit a792146837
No known key found for this signature in database
GPG Key ID: 6058CF4574298812

@ -217,7 +217,12 @@ func (i *Image) Size() (ImageSize, error) {
return Size(i.buffer) return Size(i.buffer)
} }
// Image returns the current resultant image image buffer. // Image returns the current resultant image buffer.
func (i *Image) Image() []byte { func (i *Image) Image() []byte {
return i.buffer return i.buffer
} }
// Length returns the size in bytes of the image buffer.
func (i *Image) Length() int {
return len(i.buffer)
}

@ -475,6 +475,17 @@ func TestImageSmartCrop(t *testing.T) {
Write("fixtures/test_smart_crop.jpg", buf) Write("fixtures/test_smart_crop.jpg", buf)
} }
func TestImageLength(t *testing.T) {
i := initImage("test.jpg")
actual := i.Length()
expected := 53653
if expected != actual {
t.Errorf("Size in Bytes of the image doesn't correspond. %d != %d", expected, actual)
}
}
func initImage(file string) *Image { func initImage(file string) *Image {
buf, _ := imageBuf(file) buf, _ := imageBuf(file)
return NewImage(buf) return NewImage(buf)

Loading…
Cancel
Save