thecocktail (owner)

Revisions

gist: 8841 Download_button fork
public
Description:
Nanoc plugin that flattens fireworks pngs
Public Clone URL: git://gist.github.com/8841.git
Embed All Files: show embed
sips_flatten.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Sips Flatten Filter for nanoc 2.1.1
#
# Uses the 'sips' command line tool in Mac OS X to flatten Fireworks images
# Quick hack, use at your own risk. Don't blame us if it destroys your carefully
# crafted images
 
module Nanoc::BinaryFilters
 
  class SipsFlattenFilter < Nanoc::BinaryFilter
 
    identifier :sips_flatten
 
    def run(file)
      # Get temporary file path
      tmp_file = Tempfile.new("sips_filter")
 
      flatten_format = @asset_rep.flatten_format || "png"
 
      %x(sips -s format #{flatten_format} #{file.path} --out "#{tmp_file.path}">&/dev/null)
 
      tmp_file
    end
  end
 
end