Versionning to Webp

I am running Shrine 2.16.0

locally :
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114
and have installed webp : sudo apt-get install webp

(conversion from the terminal works great)

Heroku is running the same Imagemagick version and has libwebp installed too.
“heroku 18” stack here :

So everything on Heroku should allow me to version into webp

Though I can’t do it locally. Mostly because I am very bad with mini_magick.

Please see the webp version :

process(:store) do |io, context|

  versions = { original: io } # retain original do |original|
  	pipeline = ImageProcessing::MiniMagick.source(original)
  	versions[:editable]  = pipeline.quality(90).resize_to_fit!(700, 700)
  		versions[:thumbnail] = pipeline.quality(90).resize_to_fill!(400, 400)
  		versions[:small]  = pipeline.quality(90).resize_to_fill!(200, 200)
  		versions[:webp] = pipeline.resize_to_fill!(200, 200).format("webp")

I get the following error in Rails :

Shrine::InvalidFile in PhotographesController#update

“webp” is not a valid IO object (it doesn’t respond to #read, #eof?, #rewind, #close)

Use #convert instead of #format (see #convert).

I think the order of method chaining matters because you’re using a ! method. ! methods will execute the processing on pipeline with all chainable methods up to it applied (see usage). You apply #format after the execution so I’m not sure what’s it doing with the resized image.

Try this:

versions[:webp] = pipeline.convert("webp").resize_to_fill!(200, 200)
1 Like

Thanks a lot. it works perfectly. :slightly_smiling_face:
I saw the bang but didn’t connect it would mean it would the last method to be chained…
And thanks for the link… I went to Minimagick github page first place, which is definitely not that much useful in a Shrine context…