Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: Make thumbnail

  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Make thumbnail

    I have some art on my website, I want a thumbnail next to the description, but I just want it the actual art just resized and linked to the actual large one. How can I do this using PHP GD library?
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://www.teckis.com/scriptix/thumbnails/teck.html

    GD2+

    I'll leave the page coding to you though, that just handles the thumbnailing to file aspect.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #3
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php
    include_once('folder/thumbnail_create.php');
    $variable = new Thumbnail('images/resource_name.jpg',120,120,'thumbs/output_name.jpg',85,'
        "greyscale()",
        "ellipse(\'C3DDEE\')",
        "bevel(7,\'FFFFFF\',\'111144\')",
        "round_edges(4,\'C3DDEE\',1)"'
    );
    ?>
    Can I use a gif with it?
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you PHP+GD build supports gif reading then yes you can, else no.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #5
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well,
    PHP Code:
    <?php
    include_once('thumbnail_create.php');
    $variable = new Thumbnail('art/1/brightlite8x6.gif',120,120,'art/1/8x6thumb.gif',85,'
        "greyscale()",
        "ellipse('
    C3DDEE')",
        "bevel(7,'
    FFFFFF','111144')",
        "round_edges(4,'
    C3DDEE',1)"');
    ?>
    Gives me a parse erron on line 3. What do I name this file and what is the thumbnail_create.php? and why is it included once?
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, thumbnail_create.php will be the process file that you downloaded from the linked page with all the transformation and proportional resizing algorythms contained.

    you may need to amend the include path if you uploaded it to a different directory.

    Also remember to chmod art/1 to 0777 so you can write the thumbnail to it.

    If you really fancy going overboard with all this learning type thing then you might also decide to go back to the linked page and read the text that comes between the sample code.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    SDP2006: The parse error comes from the first unescaped single quote in front of "C3DDEE". You need to escape the single quotes inside the last parameter with a backslash.

    Ökii: I find it very awkward and unintuitive that the last parameter of your Thumbnail constructor is a string with array values inside. Why not use a real array instead, with keys as the method names and the values consisting of an array of parameters for the corresponding method? You could loop through this array, check with method_exists() if this key is a method of Thumbnail, and invoke it via call_user_func_array(). Currently you use eval(), which I would try to omit, because of the side effects that can arise if bad code is passed o it. Just a quick refactoring tip.
    De gustibus non est disputandum.

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by mordred
    Ökii: I find it very awkward and unintuitive that the last parameter of your Thumbnail constructor is a string with array values inside.
    I know

    Was written quite a long time ago and I'd use a totally different approach nowadays if I was to rewrite the class. Is probably simpler for most OOP programmers to omit the last param and direct call the transformation functions singly
    $a->bevel(args);
    $a->drop_shadow(args);
    $a->create();

    Seems that most people using it aren't yet really into object programming so they just follow the instructions (well, in most cases anyway) without looking too far into the structuring.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.


  •  

    Posting Permissions

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