How to prevent Magento 2.2.8 from replacing a white background with black for GIF images?

Replace the line:

with the following one:

list($r, $g, $b) = !is_null($this->_backgroundColor) ? $this->_backgroundColor : [255, 255, 255];