Skip to content

Commit 27b723e

Browse files
author
Sezgi Kumph
committed
added custom destination image format, e.g. "GIF". defaults to "PNG"
1 parent d32fa52 commit 27b723e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/css_sprite/sprite.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ def initialize(options={})
1414

1515
@image_path = File.expand_path(File.join(Rails.root, @config['image_path'] || 'public/images'))
1616
@stylesheet_path = File.expand_path(File.join(Rails.root, @config['stylesheet_path'] || 'public/stylesheets'))
17+
18+
@format = @config['format'] ? @config['format'].downcase() : "png"
1719
end
1820

1921
# execute the css sprite operation
@@ -100,6 +102,7 @@ def output_image(directory)
100102
dest_image = composite_images(dest_image, source_image, x, y)
101103
end
102104
dest_image.image_type = @config['image_type'] ? Magick.const_get(@config['image_type']) : Magick::PaletteMatteType
105+
dest_image.format = @config['format'] || "PNG"
103106
dest_image.write(dest_image_path)
104107
end
105108
results
@@ -242,12 +245,12 @@ def all_images(directory)
242245

243246
# destination css sprite image path
244247
def dest_image_path(directory)
245-
directory + ".png"
248+
directory + "." + @format
246249
end
247250

248251
# destination css sprite image name
249252
def dest_image_name(directory)
250-
File.basename(directory) + ".png"
253+
File.basename(directory) + "." + @format
251254
end
252255

253256
# destination css file path

0 commit comments

Comments
 (0)