init(); // You must call this method to initialize the image $drawing->add_barcode($code_generated); $drawing->draw_all(); $im = $drawing->get_im(); // Next line create the little picture, the barcode is being copied inside $im2 = imagecreate($code_generated->lastX,$code_generated->lastY); imagecopyresized($im2, $im, 0, 0, 0, 0, $code_generated->lastX, $code_generated->lastY, $code_generated->lastX, $code_generated->lastY); $drawing->set_im($im2); // Header that says it is an image (remove it if you save the barcode to a file) header('Content-Type: image/png'); // Draw (or save) the image into PNG format. $drawing->finish(IMG_FORMAT_PNG); ?>