private function applyBackgroundColor(&$imageInstance, $bgColor)
    {
        $palette = new RGB();
        $color = $palette->color($bgColor);

        try {
            $topLeft = new Point(0, 0);
        } catch (InvalidArgumentException $e) {
            Craft::error($e->getMessage(), __METHOD__);
            throw new ImagerException($e->getMessage(), $e->getCode(), $e);
        }

        if ($this->imagineInstance !== null) {
            $backgroundImage = $this->imagineInstance->create($imageInstance->getSize(), $color);
            $backgroundImage->paste($imageInstance, $topLeft);
            $imageInstance = $backgroundImage;
        }
    }
private function applyBackgroundColor(&$imageInstance, $bgColor)
    {
        $palette = new RGB();
        $color = $palette->color($bgColor);

        try {
            $topLeft = new Point(0, 0);
        } catch (InvalidArgumentException $e) {
            Craft::error($e->getMessage(), __METHOD__);
            throw new ImagerException($e->getMessage(), $e->getCode(), $e);
        }

        if ($this->imagineInstance !== null) {
            $backgroundImage = $this->imagineInstance->create($imageInstance->getSize(), $color);
            $backgroundImage->paste($imageInstance, $topLeft);
            $imageInstance = $backgroundImage;
        }
    }
private function applyBackgroundColor ( & $ imageInstance , $ bgColor ) { $ palette = new RGB ( ) ; $ color = $ palette -> color ( $ bgColor ) ; try { $ topLeft = new Point ( 0 , 0 ) ; } catch ( InvalidArgumentException $ e ) { Craft :: error ( $ e -> getMessage ( ) , __METHOD__ ) ; throw new ImagerException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } if ( $ this -> imagineInstance !== null ) { $ backgroundImage = $ this -> imagineInstance -> create ( $ imageInstance -> getSize ( ) , $ color ) ; $ backgroundImage -> paste ( $ imageInstance , $ topLeft ) ; $ imageInstance = $ backgroundImage ; } }
Apply background color to image when converting from transparent to non-transparent

@param GdImage|ImagickImage|ImageInterface $imageInstance
@param string                              $bgColor

@throws ImagerException
Apply background color to image when converting from transparent to non - transparent