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