3

And I want my background to end up white instead. I've taken a look at the other questions and none of the answers seemed to really solve this problem.

I'm using Imagick version 2.3, and here's what I have:

$this->_object = new Imagick();
$this->_object->setResolution(300, 300);
$this->_object->readImage($fileRead);
$this->_object->setImageMatte(true);
$this->_object->setImageMatteColor("white");
$this->_object->setImageAlphaChannel(Imagick::ALPHACHANNEL_OPAQUE);

I've tried

setBackgroundColor, setImageBackgroundColor, composite over a white image

And none of these seem to work. Any suggestions?

chrisjbaik
  • 53
  • 7

1 Answers1

0

The jpg extension doesn't support transparency in background, you will need use png. For other site if you have for example one img with write background you could set this color in transparent with this code:

    $route  = "MiOldJpgWriteBackground.jpg";
    $salida = 'MiNewTransparentFile.png';
    exec("convert $route $salida");
    exec("convert $salida -bordercolor white -border 1x1 \
         -alpha set -channel RGBA -fuzz 10% \
         -fill none -floodfill +0+0 white \
         -shave 1x1 $salida");
    exec("rm $route");
Rubén Fanjul Estrada
  • 1,296
  • 19
  • 31
  • Sorry - I don't want a transparent background, I want a white one on a JPG (just to clarify). – chrisjbaik Feb 07 '12 at 18:00
  • With the transparency, you could put all the colours in background. In my example it code tried to change white per other colour ( just in this case per transparency), what colour do you have in background ? all the images have the same or other diferent ? – Rubén Fanjul Estrada Feb 07 '12 at 19:20