Skip to content

Commit

Permalink
Fixed padding when current height is greater than target hight
Browse files Browse the repository at this point in the history
  • Loading branch information
owahab committed Jul 10, 2011
1 parent 9369e7f commit fa30791
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/paperclip-ffmpeg.rb
Expand Up @@ -80,8 +80,12 @@ def make
width = target_width.to_i
height = (width.to_f / (@meta[:aspect].to_f)).to_i
# We should add half the delta as a padding offset Y
pad_y = (target_height.to_f - height.to_f).abs.to_i / 2
@convert_options[:vf] = "scale=#{width}:-1,pad=#{width.to_i}:#{target_height.to_i}:0:#{pad_y}:black"
pad_y = (target_height.to_f - height.to_f) / 2
if pad_y > 0
@convert_options[:vf] = "scale=#{width}:-1,pad=#{width.to_i}:#{target_height.to_i}:0:#{pad_y}:black"
else
@convert_options[:vf] = "scale=#{width}:-1,crop=#{width.to_i}:#{height.to_i}"
end
else
# Keep aspect ratio
width = target_width.to_i
Expand Down
2 changes: 1 addition & 1 deletion paperclip-ffmpeg.gemspec
Expand Up @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)

Gem::Specification.new do |s|
s.name = "paperclip-ffmpeg"
s.version = '0.6.3'
s.version = '0.6.4'
s.platform = Gem::Platform::RUBY
s.authors = ["Omar Abdel-Wahab"]
s.email = ["owahab@gmail.com"]
Expand Down

0 comments on commit fa30791

Please sign in to comment.