lib/paperclip/thumbnail.rb in paperclip-2.3.3 vs lib/paperclip/thumbnail.rb in paperclip-2.3.4
- old
+ new
@@ -43,23 +43,24 @@
# Performs the conversion of the +file+ into a thumbnail. Returns the Tempfile
# that contains the new image.
def make
src = @file
- dst = Tempfile.new([@basename, @format].compact.join("."))
+ dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
dst.binmode
begin
- options = [
- source_file_options,
- "#{ File.expand_path(src.path) }[0]",
- transformation_command,
- convert_options,
- "#{ File.expand_path(dst.path) }"
- ].flatten.compact
+ parameters = []
+ parameters << source_file_options
+ parameters << ":source"
+ parameters << transformation_command
+ parameters << convert_options
+ parameters << ":dest"
- success = Paperclip.run("convert", *options)
+ parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")
+
+ success = Paperclip.run("convert", parameters, :source => "#{File.expand_path(src.path)}[0]", :dest => File.expand_path(dst.path))
rescue PaperclipCommandLineError => e
raise PaperclipError, "There was an error processing the thumbnail for #{@basename}" if @whiny
end
dst
@@ -68,11 +69,11 @@
# Returns the command ImageMagick's +convert+ needs to transform the image
# into the thumbnail.
def transformation_command
scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)
trans = []
- trans << "-resize" << scale unless scale.nil? || scale.empty?
- trans << "-crop" << crop << "+repage" if crop
+ trans << "-resize" << %["#{scale}"] unless scale.nil? || scale.empty?
+ trans << "-crop" << %["#{crop}"] << "+repage" if crop
trans
end
end
end