public function offsetUnset($offset)
    {
        if (is_int($offset) && $offset >= 0 && $offset < $this->bands) {
            if ($this->bands === 1) {
                throw new \BadMethodCallException('Image::offsetUnset: cannot delete final band');
            }

            $components = [];
            if ($offset > 0) {
                $components[] = $this->extract_band(0, ['n' => $offset]);
            }
            if ($offset < $this->bands - 1) {
                $components[] = $this->extract_band(
                    $offset + 1,
                    ['n' => $this->bands - 1 - $offset]
                );
            }

            $head = array_shift($components);
            if (empty($components)) {
                $this->image = $head->image;
            } else {
                $this->image = $head->bandjoin($components)->image;
            }
        }
    }
public function offsetUnset($offset)
    {
        if (is_int($offset) && $offset >= 0 && $offset < $this->bands) {
            if ($this->bands === 1) {
                throw new \BadMethodCallException('Image::offsetUnset: cannot delete final band');
            }

            $components = [];
            if ($offset > 0) {
                $components[] = $this->extract_band(0, ['n' => $offset]);
            }
            if ($offset < $this->bands - 1) {
                $components[] = $this->extract_band(
                    $offset + 1,
                    ['n' => $this->bands - 1 - $offset]
                );
            }

            $head = array_shift($components);
            if (empty($components)) {
                $this->image = $head->image;
            } else {
                $this->image = $head->bandjoin($components)->image;
            }
        }
    }
public function offsetUnset ( $ offset ) { if ( is_int ( $ offset ) && $ offset >= 0 && $ offset < $ this -> bands ) { if ( $ this -> bands === 1 ) { throw new \ BadMethodCallException ( 'Image::offsetUnset: cannot delete final band' ) ; } $ components = [ ] ; if ( $ offset > 0 ) { $ components [ ] = $ this -> extract_band ( 0 , [ 'n' => $ offset ] ) ; } if ( $ offset < $ this -> bands - 1 ) { $ components [ ] = $ this -> extract_band ( $ offset + 1 , [ 'n' => $ this -> bands - 1 - $ offset ] ) ; } $ head = array_shift ( $ components ) ; if ( empty ( $ components ) ) { $ this -> image = $ head -> image ; } else { $ this -> image = $ head -> bandjoin ( $ components ) -> image ; } } }
Remove a band from an image.

@param int $offset The index to remove.

@throws \BadMethodCallException if there is only one band left in
the image
@throws Exception

@return void
Remove a band from an image .