<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -22,7 +22,8 @@ module Prawn
     # &lt;tt&gt;:position&lt;/tt&gt;::  One of (:left, :center, :right) or an x-offset
     # &lt;tt&gt;:height&lt;/tt&gt;:: the height of the image [actual height of the image]
     # &lt;tt&gt;:width&lt;/tt&gt;:: the width of the image [actual width of the image]
-    # &lt;tt&gt;:scale&lt;/tt&gt;:: scale the dimensions of the image proportionally   
+    # &lt;tt&gt;:scale&lt;/tt&gt;:: scale the dimensions of the image proportionally
+    # &lt;tt&gt;:fit&lt;/tt&gt;:: scale the dimensions of the image proportionally to fit inside [with,height]
     # 
     #   Prawn::Document.generate(&quot;image2.pdf&quot;, :page_layout =&gt; :landscape) do     
     #     pigs = &quot;#{Prawn::BASEDIR}/data/images/pigs.jpg&quot; 
@@ -51,7 +52,7 @@ module Prawn
     # (See also: Prawn::Images::PNG , Prawn::Images::JPG)
     # 
     def image(file, options={})     
-      Prawn.verify_options [:at,:position, :height, :width, :scale], options
+      Prawn.verify_options [:at,:position, :height, :width, :scale, :fit], options
       
       if file.respond_to?(:read)
         image_content = file.read
@@ -118,8 +119,8 @@ module Prawn
         bounds.absolute_right - w
       when Numeric
         options[:position] + bounds.absolute_left
-      end       
-      
+      end
+
       return [x,y]
     end
 
@@ -252,7 +253,6 @@ module Prawn
     end
 
     def calc_image_dimensions(info, options)
-      # TODO: allow the image to be aligned in a box
       w = options[:width] || info.width
       h = options[:height] || info.height
 
@@ -267,8 +267,18 @@ module Prawn
       elsif options[:scale] 
         w = info.width * options[:scale]
         h = info.height * options[:scale]
+      elsif options[:fit] 
+        bw, bh = options[:fit]
+        bp = bw / bh.to_f
+        ip = info.width / info.height.to_f
+        if ip &gt; bp
+          w = bw
+          h = bw / ip
+        else
+          h = bh
+          w = bh * ip
+        end
       end
-
       [w,h]
     end
 </diff>
      <filename>lib/prawn/images.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>50e53a09409d600d000d1e4f7b45ba9539138fab</id>
    </parent>
  </parents>
  <author>
    <name>Trym Skaar</name>
    <email>ts@skalar.no</email>
  </author>
  <url>http://github.com/sandal/prawn/commit/dc678c367065fc53e12baad242010bd1352c5422</url>
  <id>dc678c367065fc53e12baad242010bd1352c5422</id>
  <committed-date>2008-10-29T11:14:57-07:00</committed-date>
  <authored-date>2008-10-29T11:14:57-07:00</authored-date>
  <message>Added :fit argument for image()</message>
  <tree>bfa0829f33caa3789f900274454ec5ee6fabb600</tree>
  <committer>
    <name>Trym Skaar</name>
    <email>ts@skalar.no</email>
  </committer>
</commit>
