Sha256: 5edb12cfd40ba3a78579058ee8b9353df24a826a4d0704d3b1cb3542fefa913c

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

#
# File::      PNGCrush.rb
# Author::    wkm
# Copyright:: 2009
# License::   GPL
#
# Wrapper around the pngcrush program.
#
#

module SiteFuel
  module External

    require 'sitefuel/external/AbstractExternalProgram'

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

      def self.program_name
        'pngcrush'
      end

      # most likely earlier versions of pngcrush would work as well
      # but we've only ever tested it with 1.5.10
      def self.compatible_versions
        ['> 1.5']
      end

      # define options
      option :version, '-version'
      option :brute,   '-brute'
      option :reduce,  '-reduce'
      option :method,  '-method ${value}', '115'
      option :rem,     '-rem ${value}', 'alla'
      option :z,       '-z ${value}', '1'
      option :input,   '${value}'
      option :output,  '${value}'

      # uses -brute with PNGCrush to find the smallest file size, but at the
      # expense of taking quite a while to run.
      def self.brute(in_file, out_file)
        execute :brute,
                :reduce,
                :input, in_file,
                :output, out_file
      end

      # quick uses the default png crush configuration to smash up PNGs
      def self.quick(in_file, out_file)
        execute :input, in_file,
                :output, out_file
      end

      # strips out all data except the RGBA values (any copyrights, gamma, etc.)
      def self.chainsaw (in_file, out_file)
        execute :rem, 'alla',
                :reduce,
                :z, '1',
                :input, in_file,
                :output, out_file
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitefuel-0.0.0b lib/sitefuel/external/PNGCrush.rb
sitefuel-0.0.0a lib/sitefuel/external/PNGCrush.rb