spree/spree — Issue #816: Image not recognized by the 'identify' command. Upload fail.
Author: tightwork
Created: 2011-11-27 15:09:48+00:00
State: open

Hello,

Uploading images to products yield:

identify: unable to open image `/tmp/stream20111127-12723-1azbkda-0.jpg[0]': No such file or directory @ error/blob.c/OpenBlob/2589.
identify: no decode delegate for this image format `/tmp/stream20111127-12723-1azbkda-0.jpg[0]' @ error/constitute.c/ReadImage/532.
Paperclip::NotIdentifiedByImageMagickError Exception: /tmp/stream20111127-12723-1azbkda-0.jpg is not recognized by the 'identify' command.

I used ruby-debug and placed debugger in:

/usr/local/lib64/ruby/gems/1.8/gems/spree_core-0.70.2/app/models/image.rb

18 def find_dimensions
19 debugger
20 temporary = attachment.queued_for_write[:original]
21 filename = temporary.path unless temporary.nil?
22 filename = attachment.path if filename.blank?
23 geometry = Paperclip::Geometry.from_file(filename)
24 self.attachment_width = geometry.width
25 self.attachment_height = geometry.height
26 end

Running rails s --debug and attempting to upload an image, then using the rdb prompt shows Paperclip::Geometry.from_file(filename) requires the file name to have an index, example as in: index.jpg[0]. I am reading the Rdoc but I see nothing about this http://rubydoc.info/gems/paperclip/2.4.5/Paperclip/Geometry.from_file. I was able to copy the temp image in /tmp/image.jpg to /tmp/image.jpg[0] during the debug I continue, and the rdb completes without error although the image is not uploaded. There is a major problem either in the upload processing (some kind of dedup?), undocumented specifications in Paperclip, Imagemagick incompatibilities, or Spree's image processing itself.

Thank you,
Bryan

identify: no decode delegate for this image format `/tmp/stream20111127-12723-1azbkda-0.jpg[0]' @ error/constitute.c/ReadImage/532.
/usr/local/lib64/ruby/gems/1.8/gems/spree_core-0.70.2/app/models/image.rb:20
temporary = attachment.queued_for_write[:original]
(rdb:17) attachment.queued_for_write[:original]
#
(rdb:17) temporary = attachment.queued_for_write[:original]
#
(rdb:17) temporary.path
"/tmp/stream20111127-12723-1azbkda-0.jpg"
(rdb:17) filename = temporary.path
"/tmp/stream20111127-12723-1azbkda-0.jpg"
(rdb:17) filename
"/tmp/stream20111127-12723-1azbkda-0.jpg"
(rdb:17) Paperclip::Geometry.from_file(filename)
identify: unable to open image `/tmp/stream20111127-12723-1azbkda-0.jpg[0]': No such file or directory @ error/blob.c/OpenBlob/2589.
identify: no decode delegate for this image format `/tmp/stream20111127-12723-1azbkda-0.jpg[0]' @ error/constitute.c/ReadImage/532.
Paperclip::NotIdentifiedByImageMagickError Exception: /tmp/stream20111127-12723-1azbkda-0.jpg is not recognized by the 'identify' command.

-> # cp stream20111127-12723-1azbkda-0.jpg stream20111127-12723-1azbkda-0.jpg\[0\]
-> # ls stream*
stream20111127-12723-1azbkda-0.jpg stream20111127-12723-1azbkda-0.jpg[0]
root@fivenine [09:20:29] [/tmp]

(rdb:17) Paperclip::Geometry.from_file(filename)
531x800
(rdb:17) continue