Skip to content

Instantly share code, notes, and snippets.

@averyvery
Created January 11, 2012 20:11
Show Gist options
  • Save averyvery/1596529 to your computer and use it in GitHub Desktop.
Save averyvery/1596529 to your computer and use it in GitHub Desktop.
compass.rb for quanting sprites
require 'growl_notify'
GrowlNotify.config do |config|
config.notifications = ["Compass Application"]
config.default_notifications = ["Compass Application"]
config.application_name = "My Application"
end
http_path = '/'
css_dir = 'public/assets/stylesheets'
sass_dir = 'src/sass'
images_dir = 'public/assets/images'
output_style = :compressed
relative_assets = true
line_comments = false
def is_32bit?(filename)
filename.match(/transparent/)
end
def compress_png(filename)
png8_filename = filename.sub(/\.png/, '-fs8.png')
system 'src/pngquant/pngquant ' << filename
sleep 2
system 'mv -f ' << png8_filename << ' ' << filename
end
def optimize_further(image_app, filename)
system 'open -a Image' << image_app << '.app ' << filename
end
on_sprite_saved do |filename|
unless is_32bit?(filename)
compress_png filename
optimize_further 'Optim', filename
else
optimize_further 'Alpha', filename
end
GrowlNotify.moderate(:title => 'Your sprite is done: ', :description => filename)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment