no encode delegate for this image format @ error/constitute.c/WriteImage/1153

做~自己de王妃 提交于 2019-12-12 00:33:28

问题


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:inwrite' 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!