Class: ImageSqueeze::GIFToPNGProcessor

Inherits:
Processor
  • Object
show all
Defined in:
lib/image_squeeze/processors/gif_to_png_processor.rb

Instance Attribute Summary

Attributes inherited from Processor

#filename

Class Method Summary collapse

Methods inherited from Processor

handles?

Class Method Details

.input_typeObject



3
4
5
# File 'lib/image_squeeze/processors/gif_to_png_processor.rb', line 3

def self.input_type
  GIF
end

.output_extensionObject



7
8
9
# File 'lib/image_squeeze/processors/gif_to_png_processor.rb', line 7

def self.output_extension
  '.png'
end

.squeeze(filename, output_filename) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/image_squeeze/processors/gif_to_png_processor.rb', line 11

def self.squeeze(filename, output_filename)
  intermediate_tmp_filename = "%s-%s" % [output_filename, '.tmp']
  
  system("convert #{filename} PNG:#{intermediate_tmp_filename} 2> /dev/null")
  response = PNGCrushProcessor.squeeze(intermediate_tmp_filename, output_filename) # run it through PNGCrush afterwards
  
  FileUtils.rm(intermediate_tmp_filename) # clean up after ourselves
  
  response
end