Tristar
Tristar

Reputation: 13

Can't resize uploaded image

I'm using paperclip gem for uploading and resizing images. This setup works fine. I'm able to display the uploaded images. The problem comes when I try to resize the uploaded image.

Here is snippet from the model file

has_attached_file :photo,
                  :size => {:small => "150x150>"}

When I try to upload the image I get this error.

Photo /var/folders/gm/gm-SegRMHuOkSlYtTMkO8U+++TI/-Tmp-/file.jpg is not recognized by the 'identify' command.

I'm sure that the file is jpg. Here is the output of the file command

file.jpg: JPEG image data, JFIF standard 1.01, comment: "CREATOR: gd-jpeg v1.0 (using IJ"

Upvotes: 0

Views: 208

Answers (2)

bento
bento

Reputation: 2099

Have you tried any other jpg file, maybe with a simpler path also?

Upvotes: 0

Albin
Albin

Reputation: 3012

I'm not sure but in our application we do the same thing and it works. Our code looks like this:

    has_attached_file :image,
             :styles => {:small => "280x173#", :medium => "635x393#"},
             :convert_options => {:all => "-quality 80"},#, 
             :default_style => :medium,
             :default_url => "/images/study/nophoto.jpg"

    validates_attachment_size :image, :less_than => 10.megabyte
    validates_attachment_content_type :image, :content_type => ['image/gif', 'image/png', 'image/x-png', 'image/jpeg', 'image/pjpeg', 'image/jpg']

The difference I see, is that you might have to provide convert_options to be able to resize.

Upvotes: 1

Related Questions