Pass GD image object to Imagick?

倖福魔咒の 提交于 2019-12-22 08:04:23

问题


I'm generating a barcode with PEAR::Image_Barcode which uses GD, but I need to write that barcode onto a section of a PDF and PHP/Imagick seems to be the easiest way to do that, is there any way to convert a GD image object into something Imagick can work with?


回答1:


here we go:

ob_start();
 Image_Barcode::draw($barcode, 'upca', 'gif');
 $couponBarcode = ob_get_contents();
ob_end_clean();

$second = new Imagick(); 
$second->readImageBlob($couponBarcode)

it's writing the image to an output buffer with GD then reading that variable into an Imagick object




回答2:


ImageMagick has internal image creation functions. Using a barcode font you can directly create barcodes in ImageMagick. I guess ImageMagick will be more efficient in building images than PHP. Not sure about this (imageimagick's PDF functions are some times unexpected) but, as an additional bonus you may end up with vector output instead of bitmap, which will take more space and will not scale well.



来源:https://stackoverflow.com/questions/6298075/pass-gd-image-object-to-imagick

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!