Skip to content

Commit

Permalink
Fix GeometryParser regex for usage of '@>' flag
Browse files Browse the repository at this point in the history
According to the ImageMagick documentation the '@' flag is a special case that
can be used in conjunction with '>' to prevent IM from scaling an image up.
The '<' flag is ignored when using '@'.

http://www.imagemagick.org/Usage/resize/#pixel

This fixes the issue I reported in thoughtbot#1851
  • Loading branch information
alassek committed Jul 31, 2015
1 parent c819d5d commit b0e515e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/paperclip/geometry_parser_factory.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Paperclip
class GeometryParser
FORMAT = /\b(\d*)x?(\d*)\b(?:,(\d?))?([\>\<\#\@\%^!])?/i
FORMAT = /\b(\d*)x?(\d*)\b(?:,(\d?))?(\@\>|\>\@|[\>\<\#\@\%^!])?/i
def initialize(string)
@string = string
end
Expand Down
2 changes: 1 addition & 1 deletion spec/paperclip/geometry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
assert_equal 456, @upper.height
end

['>', '<', '#', '@', '%', '^', '!', nil].each do |mod|
['>', '<', '#', '@', '@>', '>@', '%', '^', '!', nil].each do |mod|
it "ensures the modifier #{description} is preserved" do
assert @geo = Paperclip::Geometry.parse("123x456#{mod}")
assert_equal mod, @geo.modifier
Expand Down

0 comments on commit b0e515e

Please sign in to comment.