Class: Blobsterix::Transformations::Impl::Image2HTML
- Inherits:
-
Transformation
- Object
- Transformation
- Blobsterix::Transformations::Impl::Image2HTML
- Defined in:
- lib/blobsterix/transformation/image_transformation.rb
Instance Method Summary collapse
- #input_type ⇒ Object
- #is_format? ⇒ Boolean
- #output_type ⇒ Object
- #transform(input_path, target_path, value) ⇒ Object
Methods inherited from Transformation
Methods included from Logable
Instance Method Details
#input_type ⇒ Object
162 163 164 |
# File 'lib/blobsterix/transformation/image_transformation.rb', line 162 def input_type() @input_type ||= Blobsterix::AcceptType.new "image/*" end |
#is_format? ⇒ Boolean
170 171 172 |
# File 'lib/blobsterix/transformation/image_transformation.rb', line 170 def is_format?() true end |
#output_type ⇒ Object
166 167 168 |
# File 'lib/blobsterix/transformation/image_transformation.rb', line 166 def output_type() @output_type ||= Blobsterix::AcceptType.new "text/html" end |
#transform(input_path, target_path, value) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/blobsterix/transformation/image_transformation.rb', line 174 def transform(input_path, target_path, value) type = "image/*" File.open(input_path) {|file| type = MimeMagic.by_magic(file).type } image = type === "image/webp" ? {:width => "unknown", :height => "unknown"} : MiniMagick::Image.open(input_path) File.open(target_path, "w") {|file| file.write("<html><body>Mimetype: #{type}<br>Width: #{image[:width]}<br>Height: #{image[:height]}</body></html>") } end |