Ruby on Rails Thursday, December 15, 2016

I am trying to convert uploaded files to Web-friendly formats using the Shrine uploader. I've followed the examples from both Shrine and the ImageProcessing spin-off project to create this:

require "image_processing/mini_magick"

class ImageUploader < Shrine
include ImageProcessing::MiniMagick
plugin :processing
plugin :versions

process(:store) do |io|
original = io.download

converted = convert(original, "png")

{original: original, png: converted}

end

end

I'm using Rails 5.0.1, I've updated ImageMagick through Homebrew, When I upload a PSD file, I get the following info back from the upload:

:original: !ruby/object:ImageUploader::UploadedFile
data:
id: 43848eddee1b26135122fea3f138a628.psd
storage: store
metadata:
filename: shrine20161215-9079-1efvqf3.psd
size: 2881972
mime_type: image/vnd.adobe.photoshop
width: 600
height: 788
:png: !ruby/object:ImageUploader::UploadedFile
data:
id: d44ea65c825a6fa1085bf7a319999ed4.png
storage: store
metadata:
filename: mini_magick20161215-9079-hpru9s.png
size: 0
mime_type: 'cannot open: No such file or directory'
width:
height:

Has anyone used Shrine to make a format conversion like this?

Thanks,

Walter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4A4CD62D-B79A-4110-AB74-0B2CB5C1EF89%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment