Code: Select all
convert /tmp/temp.png -alpha activate -channel RGBA -background "rgba(0,0,0,0.0)" -flop /tmp/temp2.png
I've tried a bunch of variants of the above, and now I've run into something TOTALLY WHACK with PHP ImageMagick extension.
Input 1:
Output:
Given this PHP script:
Code: Select all
function thumbnailImage($imagePath) {
$im = new Imagick();
$im->setBackgroundColor(new ImagickPixel('transparent'));
$im->readImage(realpath($imagePath));
$dim=$im->getImageGeometry();
if ( !isset($_GET['wh']) ) $wh=100; $wh=intval($_GET['wh']);
if ( $wh <= 0 ) $wh=100;
// $aspect=floatval($dim['width'])/floatval($dim['height']);
// $inverse_aspect=floatval($dim['height'])/floatval($dim['width']);
$width=$wh;
$height=$wh;
$im->setImageFormat("png32");
$im->thumbnailImage($width,$height, true, true);
header("Content-Type: image/png");
echo $im;
}
if ( isset($_GET['src']) ) {
try {
@thumbnailImage(urldecode($_GET['src']));
} catch ( Exception $e ) {}
}
Output appears with black background.
What gives?