8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/carrierwave/webp/converter.rb', line 8
def convert_to_webp(options = {})
manipulate! do |img|
img = yield(img) if block_given?
webp_path = "#{img.path}.webp"
old_filename = filename
::WebP.encode(img.path, webp_path, options)
instance_variable_set('@filename', "#{filename}.webp")
storage.store! SanitizedFile.new({
tempfile: webp_path, filename: webp_path,
content_type: 'image/webp'
})
instance_variable_set('@filename', old_filename)
img
end
end
|