Bug fix - stop infinite loop with +repage -crop 0x40

diff --git a/ChangeLog b/ChangeLog
index f692935..3b15795 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
     ImageListOptions parsing table. This is part of development to produce
     a "convert" replacement that can read options from both command line and
     from files or pipelines, in "Do it Immediately" handling.
+  * Crop Bug Fix. Prevent infinate loop with "+repage -crop 0x40"
 
 2011-04-18  6.6.9-6 Glenn Randers-Pehrson <glennrp@image...>
   * Added "date" to the things that can appear on the -define PNG:exclude-chunk
diff --git a/magick/transform.c b/magick/transform.c
index 5db8bed..1fd838b 100644
--- a/magick/transform.c
+++ b/magick/transform.c
@@ -922,17 +922,17 @@
       /*
         Crop into tiles of fixed size WxH.
       */
-      width=geometry.width;
-      if (width == 0)
-        width=image->page.width;
-      height=geometry.height;
-      if (height == 0)
-        height=image->page.height;
       page=image->page;
       if (page.width == 0)
         page.width=image->columns;
-      if (image->page.height == 0)
+      if (page.height == 0)
         page.height=image->rows;
+      width=geometry.width;
+      if (width == 0)
+        width=page.width;
+      height=geometry.height;
+      if (height == 0)
+        height=page.height;
       next=NewImageList();
       /*proceed=MagickTrue;
       i=0;