Q:

Paperclip is processing attachments even when they don't pass validation?

I have a model that uses paperclips for image attachments
I currently require that the attachment be an image using a validation
validates_attachment_content_type :image, :content_type => /^image\/(jpg|jpeg|pjpeg|png|x-png|gif)$/, :message => 'file type is not allowed (only jpeg/png/gif images)'

However when I try to upload a non-image I get these error messages. 
Image /var/folders/1f/0jtzzpl56sdcb92spkx6rpch0000gn/T/10-21-201120120908-44073-j59q0s.pdf is not recognized by the 'identify' command.
Image /var/folders/1f/0jtzzpl56sdcb92spkx6rpch0000gn/T/10-21-201120120908-44073-j59q0s.pdf is not recognized by the 'identify' command.
Image content type file type is not allowed (only jpeg/png/gif images)

So it seems like the file is being passed to ImageMagick even though the file does not pass the validation. I want the last error message only and not the first 2.
How can I either suppress the two first messages or make sure that the file is not processed unless it passes the content type validation?

A:

Solved with
before_post_process :process_only_images

def process_only_images
    if !(image.content_type =~ %r{^(image|(x-)?application)/(x-png|pjpeg|jpeg|jpg|png|gif)$})
      return false 
    end
end

