SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    positioning a PHP image

    I need to understand how to positition/float an image created by php. I know how to position/float JPG in PHP, but am unclear of how to position/float an image generated by PHP. This script displays a barcode in the upper left-hand corner of the page. I think the header script needs some HTML/CSS to center it on the page, but don't know what that script would look like or even if I'm on the right track.

    How would you change this script to display the header in the middle of the page?
    PHP Code:
    <?php
    require('class/BCGFont.php');
    require(
    'class/BCGColor.php');
    require(
    'class/BCGDrawing.php');
    require(
    'class/BCGpostnet.barcode.php');

    $font = new BCGFont('./class/font/Arial.ttf'18);
    $color_black = new BCGColor(000);
    $color_white = new BCGColor(255255255);

    $code = new BCGpostnet();
    $code->setScale(2);
    $code->setThickness(30);
    $code->setForegroundColor($color_black);
    $code->setBackgroundColor($color_white);
    $code->setFont($font);
    $code->parse('98000');

    // Drawing Part
    $drawing = new BCGDrawing(''$color_white);
    $drawing->setBarcode($code);
    $drawing->draw();

    header('Content-Type: image/png');

    $drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
    ?>

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,367
    Mentioned
    80 Post(s)
    Tagged
    3 Thread(s)
    What I would do is place the image on your page using normal css etc. and instead of using the image name use the php code file name.
    PHP Code:
    <img src="code_to_creat_image.php"
    You could have a problem with the headers but give this a go first

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm following you.

    What would the the actual script look like?
    <?php
    echo '<img src="include "code_to_creat_image.php"">';
    ?>
    Doesn't work.

  4. #4
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,367
    Mentioned
    80 Post(s)
    Tagged
    3 Thread(s)
    It does not need to be within the php tags as the image is created on the php page.

    This should work:

    PHP Code:
    <img src="code_to_creat_image.php"

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Got it!

    Thanks Rubble,

    Niche


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •