Class: SiteFuel::External::PNGCrush

Inherits:
AbstractExternalProgram show all
Defined in:
lib/sitefuel/external/PNGCrush.rb

Overview

Defines a gentle wrapper around the pngcrush program. This wrapper is specifically intended for use with the -reduce and -brute options.

Constant Summary

Constants inherited from AbstractExternalProgram

AbstractExternalProgram::VERSION_SEPARATOR

Instance Attribute Summary

Attributes inherited from AbstractExternalProgram

#options

Class Method Summary collapse

Methods inherited from AbstractExternalProgram

#add_option, allowed_option_name?, #apply_value, #build_command_line, call_option, capture_output, capture_stderr, compatible_version?, compatible_version_number?, create_tmp_directory, #ensure_option_validity, ensure_valid_option, excluded_option_names, #execute, execute, extract_program_version, #has_default?, #initialize, option, option?, option_default, #option_template, option_template, option_version, options, organize_options, output_handling, program_binary, program_found?, program_version, random_string, #requires_value?, #takes_value?, test_version_number, #valid_option?, verify_compatible_version, verify_program_exists, version_older?

Methods included from Logging

#debug, #error, #fatal, #info, #logger=, #warn

Constructor Details

This class inherits a constructor from SiteFuel::External::AbstractExternalProgram

Class Method Details

.brute(in_file, out_file) ⇒ Object

uses -brute with PNGCrush to find the smallest file size, but at the expense of taking quite a while to run.



42
43
44
45
46
47
# File 'lib/sitefuel/external/PNGCrush.rb', line 42

def self.brute(in_file, out_file)
  execute :brute,
          :reduce,
          :input, in_file,
          :output, out_file
end

.chainsaw(in_file, out_file) ⇒ Object

strips out all data except the RGBA values (any copyrights, gamma, etc.)



56
57
58
59
60
61
62
# File 'lib/sitefuel/external/PNGCrush.rb', line 56

def self.chainsaw (in_file, out_file)
  execute :rem, 'alla',
          :reduce,
          :z, '1',
          :input, in_file,
          :output, out_file
end

.compatible_versionsObject

most likely earlier versions of pngcrush would work as well but we’ve only ever tested it with 1.5.10



26
27
28
# File 'lib/sitefuel/external/PNGCrush.rb', line 26

def self.compatible_versions
  ['> 1.5']
end

.program_nameObject



20
21
22
# File 'lib/sitefuel/external/PNGCrush.rb', line 20

def self.program_name
  'pngcrush'
end

.quick(in_file, out_file) ⇒ Object

quick uses the default png crush configuration to smash up PNGs



50
51
52
53
# File 'lib/sitefuel/external/PNGCrush.rb', line 50

def self.quick(in_file, out_file)
  execute :input, in_file,
          :output, out_file
end