Class: ImageSqueeze::PNGToProgressiveJPEGProcessor

Inherits:
Processor
  • Object
show all
Defined in:
lib/image_squeeze/processors/png_to_progressive_jpeg_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/png_to_progressive_jpeg_processor.rb', line 3

def self.input_type
  PNG
end

.output_extensionObject



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

def self.output_extension
  '.jpg'
end

.squeeze(filename, output_filename) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/image_squeeze/processors/png_to_progressive_jpeg_processor.rb', line 11

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