开发者

convert pdf to transparent png

I'm using ImageMagick to convert a pdf file to a png (thumbn开发者_StackOverflow社区ail) image, and it works well. I'm wondering whether it's possible to convert the pdf, which has a white background, to a png file with a transparent background (i.e. set all the white pixels to transparent).

This is the PHP code i'm currently using (which results in a png file with a white background):

/* Open first page of PDF file */
$im = new imagick($pdf_filepath . '[0]');

/* Scale */
$im->thumbnailImage($width, $height);

/* Convert to png */
$im->setImageFormat('png');

/* Save file */
$result = $im->writeImage($thumbnail_filepath);


Check out: http://imagemagick.org/Usage/channels/#mask_creation

I think you will have to create it to GIF first and then back to png if you wish.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜