Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

anyone know some gd

  • 07-12-2004 06:14PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭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, Registered Users 2 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, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭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, Registered Users 2 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