Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

anyone know some gd

Options
  • 07-12-2004 6:14pm
    #1
    Registered Users Posts: 10


    I'm a student trying to do a project
    What I crave is to create an online shop for placing images on a t-shirts

    My big problem is allowing the user to dynamically resize an image on to a t-shirt, I've started this by setting up a Easyphp server and configuring it with a php extension for php_gd2. This I got working fine. I then got a lovely bit of code from
    http://www.phpbuilder.com/snippet/detail.php?type=snippet&id=1211
    And this, I think, is what I need to get going. I'm so clueless, hoping that someone can help.

    I have this code:

    <?php
    $imgfile = ($_GET);
    $percent = ($_GET);

    header('Content-type: image/jpeg');

    list($width, $height) = getimagesize($imgfile);
    $newwidth = $width * $percent;
    $newheight = $height * $percent;

    $thumb = ImageCreateTrueColor($newwidth,$newheight);
    $source = imagecreatefromjpeg($imgfile);

    imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight,
    $width, $height);

    imagejpeg($thumb);
    ?>

    also I have a script to call it with


    <img scr="resizer.php?imgfile=image.jpg&percent=0.3" border=0>


    why?????????????? :confused:


Comments

  • Closed Accounts Posts: 35 Ivan Dunaev


    why what?

    is it misprint - "<img scr=..."? may be "<img src=..." will be better?


  • Registered Users Posts: 2,426 ✭✭✭ressem


    The image tag "script", img src, is put at the point in your html at which you want the image to be displayed.

    The PHP code is saved as a file, "resizer.php" on your server. The subdirectory in which you place it depends on your server setup.


  • Registered Users Posts: 10 handandshrimp


    Thanks guys
    :) stupid spelling! but it didn't work:(. the error's i'm getting are:
    if I put php tags in
    Parse error: parse error, unexpected '<' in c:\easyphp1-7\www\test3.php on line 11
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>

    <?php
    <img src="resizer.php?imgfile=image.jpg&percent=0.3" border=0>
    ?>
    </body>
    </html>
    or if I have not php tages I get a small broken image which if I try and view with firefox I get :
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>

    <?php
    <img src="resizer.php?imgfile=image.jpg&percent=0.3" border=0>
    ?>
    </body>
    </html>
    The image “http://localhost/resizer.php?imgfile=image.jpg&percent=0.3” cannot be displayed, because it contains errors.


    I did save it as resizer.php in the right folder, although I did call the html document test3.php but I don't think that matters, does it?

    I'm pretty sure the mistake is somewhere hear, all though I might be wrong:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>


    <img src="resizer.php?imgfile=image.jpg&percent=0.3" border=0>

    </body>
    </html>
    you guys rock and thanks for the help!!!!!!!!!!


  • Registered Users Posts: 2,426 ✭✭✭ressem


    The guys that provided the php use it like
    <img border='0' src='resizer.php?imgfile=smp.jpg&percent=0.6'>
    

    http://smallcapitalbusiness.com/resizer/sample.php
    Choose a new size and view source.


  • Registered Users Posts: 10 handandshrimp


    Just wanted to say a big thank you!!!! YOU’RE A GENIUS!!!! Thank you sooo much!!! It’s exactly what I need!!! XXX


  • Advertisement
Advertisement