lib/chunky_png/canvas/operations.rb
# Trims the border around the image in place.
#
# @param [Integer] border The color to attempt to trim.
# @return [ChunkyPNG::Canvas] Returns itself, but with the border
#  trimmed.
# @see #trim
Trims the border around the image in place.
Trims the border around the image in place .
def trim!(border = pixels.first)
        x1 = [*0...width].index   { |c| column(c).uniq != [border] }
        x2 = [*0...width].rindex  { |c| column(c).uniq != [border] }
        y1 = [*0...height].index  { |r|    row(r).uniq != [border] }
        y2 = [*0...height].rindex { |r|    row(r).uniq != [border] }
        crop! x1, y1, x2 - x1 + 1, y2 - y1 + 1
      end
def trim! ( border = pixels . first ) x1 = [ * 0 ... width ] . index { | c | column ( c ) . uniq != [ border ] } x2 = [ * 0 ... width ] . rindex { | c | column ( c ) . uniq != [ border ] } y1 = [ * 0 ... height ] . index { | r | row ( r ) . uniq != [ border ] } y2 = [ * 0 ... height ] . rindex { | r | row ( r ) . uniq != [ border ] } crop! x1 , y1 , x2 - x1 + 1 , y2 - y1 + 1 end
Trims the border around the image in place.
Trims the border around the image in place .
Returns itself, but with the border trimmed.
Returns itself but with the border trimmed .
ChunkyPNG::Canvas
border
<not_specific>
pixels
<not_specific>
first
<not_specific>
<not_specific>
border The color to attempt to trim.
border The color to attempt to trim .
see
None