Fwd: [PEAR] Image/Barcode
| From: | Richard Quadling | Date: | Sat, 23 Apr 2011 16:41:40 +0000 |
| Subject: | Fwd: [PEAR] Image/Barcode | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-31078@lists.php.net to get a copy of this message | ||
---------- Forwarded message ----------
From: Richard Quadling <rquadling@gmail.com>
Date: 23 April 2011 04:18
Subject: Re: [PEAR] Image/Barcode
To: Alejandro Crosa <alecros@ymail.com>
On 22 April 2011 17:49, Alejandro Crosa <alecros@ymail.com> wrote:
>
>
> Richard-
> I want to know if the sintaxis is ok....the '/Image...' directory path...... what
> file must be put there? I try change it many times...but I do not doing very well.
> I understand the idea that you tell me...and I know that must be working very well...but I
> want to be sure that the sintaxis is ok...for example...$bc-> must be write?...the path of
> destiny of the file to save the image must be absolute as C:\......\file.php? or only the name of
> the file? for example code.png?...
> Which header must be write?
> I can see some example?
> I try with this
> <?php
> $string=$_POST["value"];
> require_once 'Image/Barcode.php';
> Image_Barcode::draw($string, "code128", "png");
> ?>
> where $string take the value of the number to print from other script....then my idea is do
> full the script by adding
>
> imagepng($bc->draw('123456789','code128','png',false),'file.php');
> imagedestroy($im);
> where file.php is the destiny place of the codebar image.
>
> Excuse me for insist....and thanks very much for you attention.
>
> Best regards
>
> --- El vie 22-abr-11, Richard Quadling <rquadling@gmail.com> escribió:
>
> De: Richard Quadling <rquadling@gmail.com>
> Asunto: Re: [PEAR] Image/Barcode
> Para: "Alejandro Crosa" <alecros@ymail.com>
> Cc: RQuadling@googlemail.com
> Fecha: viernes, 22 de abril de 2011, 9:23
>
> On 21 April 2011 21:26, Alejandro Crosa <alecros@ymail.com> wrote:
> >
> >
> > Hi...
> >
> > I am using this in php for save an image of barcode in a file
> >
> >
> > imagepng($bc->draw("123456789","code128","png",false),"/images/barcode.png");
> >
> > but this do not work
> >
> > Later I try with this
> >
> >
> > imagepng(draw("123456789","code128","png",false),"/images/barcode.png");
> > ...but do not work....
> >
> > I want to save an image of code128 generated by draw() class in a file and I can not do
> > it.
> >
> > This is well used?
> > Thanks
> >
> >
>
> You say "does not work". What errors are you getting? Are you
> displaying all errors?
>
> Most likely /images is a non existent directory.
>
>
> --
> Richard Quadling
> Twitter : EE : Zend
> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
<?php
require_once 'Image/Barcode/Code39.php';
$s_Data = 'CODE39DATA';
$o_BarCode = Image_Barcode::draw($s_Data, 'Code39', 'png', False);
imagepng($o_BarCode, './image2.png');
imagedestroy($o_BarCode);
?>
produces the attached png file.
But it also produced the following text output ...
Warning: imagefontheight() expects parameter 1 to be long, string
given in C:\PHP5\PEAR\Image\Barcode\Code39.php on line 186
Warning: imagefontwidth() expects parameter 1 to be long, string given
in C:\PHP5\PEAR\Image\Barcode\Code39.php on line 187
Warning: imagestring() expects parameter 2 to be long, string given in
C:\PHP5\PEAR\Image\Barcode\Code39.php on line 225
So, like I said, if you use header() to issue the content type early
on, the headers corrupt the output of the image when it is sent to the
browser.
You will need to suppress the errors by adding an @ ...
$o_BarCode = @Image_Barcode::draw($s_Data, 'Code39', 'png', False);
That will suppress the errors.
So, if you wanted to output the headers and then issue ...
header('Content-type: image/png');
@Image_Barcode::draw($s_Data, 'Code39', 'png');
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY