File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff 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.
221221func (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+ }
Original file line number Diff line number Diff 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+
478489func initImage (file string ) * Image {
479490 buf , _ := imageBuf (file )
480491 return NewImage (buf )
You can’t perform that action at this time.
0 commit comments