Skip to content

Commit 6e9a8a8

Browse files
authored
Merge pull request #164 from greut/length
Add Image.Length
2 parents 75a5d92 + a792146 commit 6e9a8a8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

image.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@ func (i *Image) Size() (ImageSize, error) {
217217
return Size(i.buffer)
218218
}
219219

220-
// Image returns the current resultant image image buffer.
220+
// Image returns the current resultant image buffer.
221221
func (i *Image) Image() []byte {
222222
return i.buffer
223223
}
224+
225+
// Length returns the size in bytes of the image buffer.
226+
func (i *Image) Length() int {
227+
return len(i.buffer)
228+
}

image_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,17 @@ func TestImageSmartCrop(t *testing.T) {
475475
Write("fixtures/test_smart_crop.jpg", buf)
476476
}
477477

478+
func TestImageLength(t *testing.T) {
479+
i := initImage("test.jpg")
480+
481+
actual := i.Length()
482+
expected := 53653
483+
484+
if expected != actual {
485+
t.Errorf("Size in Bytes of the image doesn't correspond. %d != %d", expected, actual)
486+
}
487+
}
488+
478489
func initImage(file string) *Image {
479490
buf, _ := imageBuf(file)
480491
return NewImage(buf)

0 commit comments

Comments
 (0)