module ChunkyPNG::Canvas::Operations
def trim!(border = pixels.first)
- See: #trim -
Returns:
-
(ChunkyPNG::Canvas)
- Returns itself, but with the border
Parameters:
-
border
(Integer
) -- The color to attempt to trim.
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