Code: Select all
convert -size 640x480 xc:none -fill white -draw 'roundRectangle 15,15 624,464 15,15' logo: -compose SrcIn -composite result.png
Code: Select all
<?php
$logoWand = NewMagickWand();
MagickReadImage( $logoWand, '/tmp/logo.png' );
$maskWand = NewDrawingWand();
DrawSetFillColor( $maskWand, NewPixelWand( 'white' ) );
DrawRoundRectangle( $maskWand, 15,15, 624,464, 15,15 );
DrawMatte( $maskWand, 0, 0, MW_FloodfillMethod );
DrawComposite( $maskWand, MW_SrcInCompositeOp, 0, 0, 640, 480, $logoWand );
// Save composited image
$outWand = NewMagickWand();
MagickNewImage( $outWand, 640, 480 );
MagickDrawImage( $outWand, $maskWand );
MagickWriteImage( $outWand, '/tmp/logo_masked.png' );
// Output to browser
header("Content-Type: image/png");
header("Content-Length: " . filesize('/tmp/logo_masked.png'));
$fh = fopen( '/tmp/logo_masked.png', 'r' );
fpassthru( $fh );
die;
?>