Permalink
Browse files

Added height and width convenience methods

  • Loading branch information...
1 parent 34d8667 commit 56ed013c3306cc873ef8023cfe41c534f5b9c8a3 @tobi committed May 1, 2012
Showing with 25 additions and 0 deletions.
  1. +8 −0 gm.go
  2. +17 −0 gm_test.go
View
8 gm.go
@@ -69,6 +69,14 @@ func (img *Image) OpenFile(filename string) error {
return nil
}
+func (img *Image) Width() int64 {
+ return int64(C.MagickGetImageWidth(img.wand))
+}
+
+func (img *Image) Height() int64 {
+ return int64(C.MagickGetImageHeight(img.wand))
+}
+
func (img *Image) OpenBlob(bytes []byte) error {
if len(bytes) < 1 {
return BlobEmpty
View
@@ -21,6 +21,23 @@ func TestOpenNonExisting(t *testing.T) {
}
}
+func TestHeightWidth(t *testing.T) {
+ img := Open("./assets/image.jpg")
+ if img == nil {
+ t.Fail()
+ }
+ if img.Width() != 600 {
+ log.Printf("%d", img.Width())
+ t.Fail()
+ }
+
+ if img.Height() != 399 {
+ log.Printf("%d", img.Height())
+ t.Fail()
+ }
+
+}
+
func TestResizeSuccess(t *testing.T) {
img := Open("./assets/image.jpg")

0 comments on commit 56ed013

Please sign in to comment.