...

View Full Version : Make thumbnail



SDP2006
10-11-2003, 02:57 PM
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?

Íkii
10-11-2003, 03:02 PM
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.

SDP2006
10-11-2003, 03:21 PM
<?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?

Íkii
10-11-2003, 03:32 PM
If you PHP+GD build supports gif reading then yes you can, else no.

SDP2006
10-11-2003, 03:45 PM
Well,


<?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?

Íkii
10-11-2003, 08:11 PM
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. ;)

mordred
10-11-2003, 10:49 PM
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. ;)

Íkii
10-12-2003, 10:55 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum