问题
I'm using Paperclip, ImagMagick, Rmagick, Amazon-s3
I'm getting this error when getting an image from url and after custom resizing image replacing the changed image to amazon.
Magick::ImageMagickError (no encode delegate for this image format //s3.amazonaws.com/beu-dev/temp_images/final_images/000/000/377/original/template_37720121205-5921-99989h.png' @ error/constitute.c/WriteImage/1153):
app/models/temp_image.rb:38:in
write'
line#38 is last line before end of this method
def reprocess_final_image
image_file_url = self.final_image.url(:original).split('?')[0]
thumb = Magick::Image.read(image_file_url).first
thumb.format = "PNG"
thumb.crop_resized!(240,200, Magick::NorthWestGravity)
**thumb.write(image_file_url)** ***Line#38***
end
Note: One more thing This code works perfectly when using system file system, but when started using amazon s3 Error happening
回答1:
I think you need to use the local file name instead of URL. Imagemagick can't just write the file to URL via http. To replace the source file you need to use the Amazon S3 API.
thumb.crop_resized!(240,200, Magick::NorthWestGravity)
thumb.write(local_temp_file_name)
# abstract Amazon S3 API. Use your favorite API
S3Object.store(local_temp_file_name, open(local_temp_file_name))
回答2:
Issue solved.
1. Check "identify -list format"
If you don't see the .jpeg format in the list. Then you need to add the .jpeg library.
curl -O http://www.ijg.org/files/jpegsrc.v8c.tar.gz
tar zxvf jpegsrc.v8c.tar.gz
cd jpeg-8c/
./configure
make
Sudo make install
Now reinstall imagemagick then everything works fine now.
来源:https://stackoverflow.com/questions/13724057/no-encode-delegate-for-this-image-format-error-constitute-c-writeimage-1153