in reply to Re: Adding text to an image for printing
in thread Adding text to an image for printing

That's great, pme, thanks!

It's good to have that (rather concise) code, which I might use for something else someday, but I'm not sure I can use it in my exact scenario, because of some requirements that I didn't think to explain before, i.e. the users might be printing say 20 course certificates for students, (which are always 2 per A4 page).  So, if I put all 20 in a 10 page PDF, the users can just download that single PDF, open it, and print it.

Would there be a quick & easy way to achieve the same thing using PNGs which were created by GD?

  • Comment on Re^2: Adding text to an image for printing

Replies are listed 'Best First'.
Re^3: Adding text to an image for printing
by pme (Monsignor) on Nov 30, 2014 at 08:36 UTC
    Hi tel2,

    Check out this: http://search.cpan.org/~lds/GD-2.56/lib/GD.pm

    Using GD one can create empty canvas and then draw what you want and save in many different formats when ready.

    Using GD even you can insert a small marker image to a given position into a big picture.

    $myImage = new GD::Image(100,100); ... various drawing stuff ... $srcImage = new GD::Image(50,50); ... more drawing stuff ... # copy a 25x25 pixel region from $srcImage to # the rectangle starting at (10,10) in $myImage $myImage->copy($srcImage,10,10,0,0,25,25);

    Regards

      Thanks pme, but I'm sorry, I don't see how that addresses the last point I made.

      Are you still saying I could use GD to do what I want (i.e. create a single file for users to download & print, which could have 10 pages containing 2 images per page), without putting them in a PDF?  If so, how (I'm not asking for code now, just process and file formats, i.e. what kind of container can the graphics+text be put in which can contain many pages for printing 2 certificates per page)?  Or when you say "different formats", are you including PDF in that list of formats?
      (I guess multipage TIFF is one option, but I'm not sure I want to go that way, because, for one thing, the users might struggle with it.)

      Thanks.
      tel2

        Hi tel2, Sorry for not answering soo long. You can do the format conversion with ImagMagick as RonW suggested below. Regards
Re^3: Adding text to an image for printing
by RonW (Parson) on Dec 01, 2014 at 22:45 UTC

    Image::Magick can write PDFs. It looks like you could convert a series of PNGs (or whatever) into a PDF. Also, you might be to skip GD and add the text to the image in Image::Magick.

    Disclaimer: I have not tried this. YMMV.

      OK, thanks Ron.