SitePoint Sponsor |
|
User Tag List
Results 1 to 11 of 11
Thread: GD libary tutorials
Hybrid View
-
Jun 11, 2003, 08:22 #1
- Join Date
- Jun 2003
- Location
- Hull
- Posts
- 36
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
GD libary tutorials
Just run the phpinfo on my account and it says I have the following:
GD Support: enabled
GD Version: 1.6.2 or higher
FreeType Support: enabled
FreeType Linkage with: TTF library
JPG Support: enabled
PNG Support: enabled
WBMP Support: enabled
WHat I wanted to know is can anyone recommend a good tutorial on creating an image gallery with on the fly thumbnails.
TIA
-
Jun 11, 2003, 09:43 #2
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Umm....1) www.phpbuilder.com 2) www.devshed.com 3) www.wdvl.com and numerous other sites, though not all tutorials are of decent quality etc
-
Jun 11, 2003, 10:03 #3
- Join Date
- Oct 2002
- Location
- Iceland
- Posts
- 1,238
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
/me slaps Dr Livingstone for not mentioning Sitepoint
http://www.sitepoint.com/article/937
Haven't read it though (shame on me I know...).- website
-
Jun 11, 2003, 10:05 #4
- Join Date
- Oct 2002
- Location
- Iceland
- Posts
- 1,238
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I would look at this http://www.phpbuilder.com/columns/in...at=2&subcat=17
- website
-
Jun 11, 2003, 12:55 #5
- Join Date
- Dec 2002
- Location
- Manchester UK
- Posts
- 310
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
IMHO resizing images using the gd lib sucks unless you are using GD2+ then you can use 'imagecreatetruecolor'
the mog
-
Jun 11, 2003, 14:53 #6
- Join Date
- Oct 2002
- Location
- Iceland
- Posts
- 1,238
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by The Mog
Dr Livingston, yes it is definitely time to change!- website
-
Jun 11, 2003, 12:57 #7
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Umm... Time I upgraded then ? Website - I'll slap you back remember
-
Jun 11, 2003, 13:19 #8
- Join Date
- Dec 2002
- Location
- Manchester UK
- Posts
- 310
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
And finally (20 min later) here is the code you would need
PHP Code:<?
if ($mode == "small") {
$thumbnailsize = 100;
} else if ($mode == "medium") {
$thumbnailsize = 160;
} else if ($mode == "large") {
$thumbnailsize = 350;
}
$path = "images/$file";
$img = ImageCreateFromJPEG($path);
$originalX = imagesx($img);
$originalY = imagesy($img);
if ($originalX > $originalY) {
$sf = (double) $thumbnailsize / $originalX;
} else {
$sf = (double) $thumbnailsize / $originalY;
}
$neww = $originalX * $sf;
$newh = $originalY * $sf;
$tn = ImageCreateTrueColor($neww, $newh);
ImageCopyResampled($tn, $img, 0,0,0,0, $neww, $newh, $originalX, $originalY);
Header("Content-Type: image/jpeg");
ImageJPEG($tn);
ImageDestroy($tn);
ImageDestroy($img);
?>
<img src="resize.php?file=imageName.jpg&mode=small">
The Mog
-
Jun 11, 2003, 14:16 #9
- Join Date
- Jun 2003
- Location
- Hull
- Posts
- 36
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
cheers for that ;-)
-
Jun 11, 2003, 14:18 #10
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's all dependant on register_globals though
add:
PHP Code:$mode = $_REQUEST['mode'];
$file = $_REQUEST['file'];
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
Jun 11, 2003, 14:58 #11
- Join Date
- Nov 2001
- Location
- UK
- Posts
- 466
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
that's a GD2+ scriptlet as it uses both imagecreatetruecolor and imagecopyresampled. If those functions will not work on your build, I'd suggest reading the sitepoint article linked above which teaches a trick for raising the palette indices from 256 to 16.7million and thus produces much better images.
If you do have GD2+ you may be interested in a thumbnailing class I also wrote which has a range of effects such as drop shadow, bevel, ellipse, overlay, greyscale etc - located at http://vextron.mirrors.phpclasses.or...kage/1007.html
Bookmarks