diff --git a/coders/caption.c b/coders/caption.c
index b5e8654..12620f5 100644
--- a/coders/caption.c
+++ b/coders/caption.c
@@ -212,12 +212,12 @@
         height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5);
         if ((image->columns != 0) && (image->rows != 0))
           {
-            if ((width > image->columns) && (height > image->rows))
+            if ((width >= image->columns) && (height >= image->rows))
               break;
           }
         else
-          if (((image->columns != 0) && (width > image->columns)) ||
-              ((image->rows != 0) && (height > image->rows)))
+          if (((image->columns != 0) && (width >= image->columns)) ||
+              ((image->rows != 0) && (height >= image->rows)))
             break;
       }
       high=draw_info->pointsize;
@@ -238,7 +238,7 @@
         height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5);
         if ((image->columns != 0) && (image->rows != 0))
           {
-            if ((width <= image->columns) && (height <= image->rows))
+            if ((width < image->columns) && (height < image->rows))
               low=draw_info->pointsize+1.0;
             else
               high=draw_info->pointsize-1.0;