protected function _trimColor($background = 'transparent')
    {
        $width = $this->width();
        $height = $this->height();

        $b_top = 0;
        $b_lft = 0;
        $b_btm = $height - 1;
        $b_rt = $width - 1;

        //top
        for (; $b_top < $height; ++$b_top) {
            for ($x = 0; $x < $width; ++$x) {
                if ($this->getColor($x, $b_top) != $background) {
                    break 2;
                }
            }
        }

        // bottom
        for (; $b_btm >= 0; --$b_btm) {
            for ($x = 0; $x < $width; ++$x) {
                if ($this->getColor($x, $b_btm) != $background) {
                    break 2;
                }
            }
        }

        // left
        for (; $b_lft < $width; ++$b_lft) {
            for ($y = $b_top; $y <= $b_btm; ++$y) {
                if ($this->getColor($b_lft, $y) != $background) {
                    break 2;
                }
            }
        }

        // right
        for (; $b_rt >= 0; --$b_rt) {
            for ($y = $b_top; $y <= $b_btm; ++$y) {
                if ($this->getColor($b_rt, $y) != $background) {
                    break 2;
                }
            }
        }

        ++$b_btm;
        ++$b_rt;

        $this->crop($b_lft, $b_top, $b_rt - $b_lft, $b_btm - $b_top);
    }