Skip to content

Commit 47b975d

Browse files
committed
add .size
see libvips#58
1 parent d090e27 commit 47b975d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* add a Valgrind suppressions file [John Cupitt]
1010
* fix .monotonic? [John Cupitt]
1111
* fix .data on coded images [John Cupitt]
12+
* add .size, see issue #58 [John Cupitt]
1213

1314
# Version 0.3.8
1415

ext/header.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,24 @@ header_y_size(VALUE obj)
7878
return Qnil;
7979
}
8080

81+
/*
82+
* call-seq:
83+
* im.size -> [width, height]
84+
*
85+
* Get the size of the image in pixels.
86+
*/
87+
88+
static VALUE
89+
header_size(VALUE obj)
90+
{
91+
GetImg(obj, data, im);
92+
93+
if (im)
94+
return rb_ary_new3(2, INT2FIX(im->Xsize), INT2FIX(im->Ysize));
95+
96+
return Qnil;
97+
}
98+
8199
/*
82100
* call-seq:
83101
* im.bands -> number
@@ -403,6 +421,7 @@ init_Header( void )
403421

404422
rb_define_method(mVIPSHeader, "x_size", header_x_size, 0);
405423
rb_define_method(mVIPSHeader, "y_size", header_y_size, 0);
424+
rb_define_method(mVIPSHeader, "size", header_size, 0);
406425
rb_define_method(mVIPSHeader, "bands", header_bands, 0);
407426
rb_define_method(mVIPSHeader, "band_fmt", header_band_fmt, 0);
408427
rb_define_method(mVIPSHeader, "x_res", header_x_res, 0);

0 commit comments

Comments
 (0)