<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/fixtures/files/rails.pdf</filename>
    </added>
    <added>
      <filename>test/pdf_attachment_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,6 @@
+* Sep 18 2008 *
+* support thumbnailing of PDF files into PNG files with rmagick processor
+
 * Apr 17 2008 *
 * amazon_s3.yml is now passed through ERB before being passed to AWS::S3 [Fran&#231;ois Beausoleil]
 </diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -26,30 +26,31 @@ In the model there are two methods made available by this plugins: has_attachmen
 
 has_attachment(options = {})
   This method accepts the options in a hash:
-    :content_type     # Allowed content types.
-                      # Allows all by default.  Use :image to allow all standard image types.
-    :min_size         # Minimum size allowed.
-                      # 1 byte is the default.
-    :max_size         # Maximum size allowed.
-                      # 1.megabyte is the default.
-    :size             # Range of sizes allowed.
-                      # (1..1.megabyte) is the default.  This overrides the :min_size and :max_size options.
-    :resize_to        # Used by RMagick to resize images.
-                      # Pass either an array of width/height, or a geometry string.
-    :thumbnails       # Specifies a set of thumbnails to generate.
-                      # This accepts a hash of filename suffixes and RMagick resizing options.
-                      # This option need only be included if you want thumbnailing.
-    :thumbnail_class  # Set which model class to use for thumbnails.
-                      # This current attachment class is used by default.
-    :path_prefix      # path to store the uploaded files.
-                      # Uses public/#{table_name} by default for the filesystem, and just #{table_name} for the S3 backend.  
-                      # Setting this sets the :storage to :file_system.
-    :partition        # Partiton files in directories like /0000/0001/image.jpg. Default is true. 
-    :storage          # Specifies the storage system to use..
-                      # Defaults to :db_file.  Options are :file_system, :db_file, and :s3.
-    :processor        # Sets the image processor to use for resizing of the attached image.
-                      # Options include ImageScience, Rmagick, and MiniMagick.  Default is whatever is installed.
-    
+    :content_type       # Allowed content types.
+                        # Allows all by default.  Use :image to allow all standard image types.
+    :min_size           # Minimum size allowed.
+                        # 1 byte is the default.
+    :max_size           # Maximum size allowed.
+                        # 1.megabyte is the default.
+    :size               # Range of sizes allowed.
+                        # (1..1.megabyte) is the default.  This overrides the :min_size and :max_size options.
+    :resize_to          # Used by RMagick to resize images.
+                        # Pass either an array of width/height, or a geometry string.
+    :thumbnails         # Specifies a set of thumbnails to generate.
+                        # This accepts a hash of filename suffixes and RMagick resizing options.
+                        # This option need only be included if you want thumbnailing.
+    :thumbnail_class    # Set which model class to use for thumbnails.
+                        # This current attachment class is used by default.
+    :path_prefix        # path to store the uploaded files.
+                        # Uses public/#{table_name} by default for the filesystem, and just #{table_name} for the S3 backend.  
+                        # Setting this sets the :storage to :file_system.
+    :partition          #  Partiton files in directories like /0000/0001/image.jpg. Default is true. 
+    :storage            # Specifies the storage system to use..
+                        # Defaults to :db_file.  Options are :file_system, :db_file, and :s3.
+    :processor          # Sets the image processor to use for resizing of the attached image.
+                        # Options include ImageScience, Rmagick, and MiniMagick.  Default is whatever is installed.
+    :thumbnail_pdf_files # Defaults to false. Set to true if pdf files should be converted into PNG file thumbnails
+                         # only supported for rmagick processor
 
   Examples:
     has_attachment :max_size =&gt; 1.kilobyte</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+require 'ruby-debug'
+
 module Technoweenie # :nodoc:
   module AttachmentFu # :nodoc:
     @@default_processors = %w(ImageScience Rmagick MiniMagick Gd2 CoreImage)
@@ -232,6 +234,7 @@ module Technoweenie # :nodoc:
 
       # Returns true/false if an attachment is thumbnailable.  A thumbnailable attachment has an image content type and the parent_id attribute.
       def thumbnailable?
+        #debugger
         (image? || (pdf? &amp;&amp; attachment_options[:thumbnail_pdf_files] &amp;&amp; supports_pdf?)) &amp;&amp; respond_to?(:parent_id) &amp;&amp; parent_id.nil?
       end
 
@@ -251,7 +254,7 @@ module Technoweenie # :nodoc:
         ext.sub!(/gif$/, 'png') if attachment_options[:processor] == &quot;ImageScience&quot;
         
         # Change the output extension if PDFs are being converted
-        ext = &quot;.png&quot; if attachment_options[:thumbnail_pdf_files]
+        ext = &quot;.png&quot; if attachment_options[:thumbnail_pdf_files] &amp;&amp; respond_to?(:parent) &amp;&amp; parent &amp;&amp; parent.pdf?
         
         &quot;#{basename}_#{thumbnail}#{ext}&quot;
       end
@@ -415,10 +418,17 @@ module Technoweenie # :nodoc:
 
         # validates the size and content_type attributes according to the current model's options
         def attachment_attributes_valid?
-          [:size, :content_type].each do |attr_name|
+          
+          [:size].each do |attr_name|
             enum = attachment_options[attr_name]
-            #errors.add attr_name, ActiveRecord::Errors.default_error_messages[:inclusion] unless enum.nil? || enum.include?(send(attr_name))
+            errors.add attr_name, ActiveRecord::Errors.default_error_messages[:inclusion] unless enum.nil? || enum.include?(send(attr_name))
           end
+          #validate content type separately because a PDF could have a thumbnail of type image/png which the model may not allow
+          content_types = attachment_options[:content_type]
+          content_types &lt;&lt; &quot;image/png&quot; if content_types &amp;&amp; self.respond_to?(:parent) &amp;&amp; self.parent &amp;&amp; self.parent.pdf? &amp;&amp; process_pdfs?
+          errors.add :content_type, ActiveRecord::Errors.default_error_messages[:inclusion] unless content_types.nil? || content_types.include?(send(:content_type))
+
+          
         end
 
         # Initializes a new thumbnail with the given suffix.</diff>
      <filename>lib/technoweenie/attachment_fu.rb</filename>
    </modified>
    <modified>
      <diff>@@ -24,7 +24,7 @@ module Technoweenie # :nodoc:
           end
           
           def supports_pdf?
-            true
+            false
           end
         end
 </diff>
      <filename>lib/technoweenie/attachment_fu/processors/mini_magick_processor.rb</filename>
    </modified>
    <modified>
      <diff>@@ -50,7 +50,7 @@ module Technoweenie # :nodoc:
             img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols&lt;1 ? 1 : cols, rows&lt;1 ? 1 : rows) }
           end
           img.strip! unless attachment_options[:keep_profile]
-          if parent &amp;&amp; parent.pdf? &amp;&amp; process_pdfs?
+          if respond_to?(:parent) &amp;&amp; parent &amp;&amp; parent.pdf? &amp;&amp; process_pdfs?
             output_format = 'PNG'
           else
             output_format = img.format</diff>
      <filename>lib/technoweenie/attachment_fu/processors/rmagick_processor.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,6 +20,12 @@ class PdfAttachment &lt; Attachment
   has_attachment :content_type =&gt; 'pdf'
 end
 
+class PdfWithThumbsAttachment &lt; Attachment
+  has_attachment :content_type =&gt; 'pdf', 
+                 :thumbnails =&gt; { :thumb =&gt; [50, 50]},
+                 :thumbnail_pdf_files =&gt; true
+end
+
 class DocAttachment &lt; Attachment
   has_attachment :content_type =&gt; %w(pdf doc txt)
 end</diff>
      <filename>test/fixtures/attachment.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a2891c676a4d81863c91c8039ec0cc49ada3f4f2</id>
    </parent>
  </parents>
  <author>
    <name>James Kebinger</name>
    <email>jkk@james-kebingers-macbook-pro.local</email>
  </author>
  <url>http://github.com/jkebinger/attachment_fu/commit/b8df48db8b28ec46380de2daaac13c5d3ab5cfeb</url>
  <id>b8df48db8b28ec46380de2daaac13c5d3ab5cfeb</id>
  <committed-date>2008-09-18T14:04:13-07:00</committed-date>
  <authored-date>2008-09-18T14:04:13-07:00</authored-date>
  <message>thumbnailing of PDF files to PNGs supported for rmagick</message>
  <tree>aedaa43a2b5bdd06cc38602dcdbf267e27ce5da8</tree>
  <committer>
    <name>James Kebinger</name>
    <email>jkk@james-kebingers-macbook-pro.local</email>
  </committer>
</commit>
