Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass GD image object to Imagick?

Tags:

php

pear

gd

imagick

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?

like image 216
JKirchartz Avatar asked Jan 20 '23 13:01

JKirchartz


1 Answers

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

like image 139
JKirchartz Avatar answered Jan 31 '23 01:01

JKirchartz