Ruby gem 从 PNG 生成 GIF CSS 精灵?
是否有 Ruby gem 可以通过将 PNG 图像组合成 GIF 来生成 CSS 精灵?
我正在寻找一个支持命令行的。我找到了几个,但它们要么只能与 Rails 配合使用,要么只能生成 PNG 精灵,而不能生成 gif。
Is there a Ruby gem that can generate CSS sprites from PNG images by combining them into a GIF?
I am looking for one that supports command line. I found several but they either work only with Rails or can only produce PNG sprites, never gifs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GIF 的另一个重要警告是,您只能使用 256 色调色板,这对于单个图像来说通常没问题,但如果精灵的调色板差异很大,则可能会出现问题。无论如何...
css_sprite (此宝石搜索)看起来是您最好的选择。
您可能自己发现了它并忽略了它,因为它似乎依赖于Rails。然而,查看代码表明 事实上它没有t。只要指定了配置文件,按指定运行它就应该可以工作。*
*它看起来像
css_sprite:build
Rake 任务可能在没有 Rails 的情况下中断(因为它不需要 lib/automatic.rb,它“伪造”Rails.root),但使用 rake css_sprite:start 应该可以正常工作。Another big caveat with GIF is that you're limited to a 256-color palette, which is often fine for a single image but could be problematic if your sprites vary widely in palette. Regardless...
css_sprite (the first result for this gem search) looks like your best bet.
You probably found it on your own and disregarded it because it appears to depend on Rails. However, peeking at the code shows that in fact it doesn't. Running it as specified should work as long as your configuration file is specified.*
*It looks like the
css_sprite:build
Rake task might break without Rails (because it doesn't requirelib/automatic.rb
, which "fakes"Rails.root
) but usingrake css_sprite:start
should work fine.