GD Thumbnails
Hi
Please can anyone help?
I know how to make images uploaded, into thumbnails via "GD"
but not how to make a thumbnail of a
image hosted elsewhere, can this be done using GD?
Many thanks for any help!
Hi
Please can anyone help?
I know how to make images uploaded, into thumbnails via "GD"
but not how to make a thumbnail of a
image hosted elsewhere, can this be done using GD?
Many thanks for any help!
Megan posted this at 14:56 — 23rd October 2005.
She has: 11,421 posts
Joined: Jun 1999
What is "GD"???
lengoundry posted this at 10:21 — 25th October 2005.
He has: 4 posts
Joined: Mar 2002
THANKS EVERYONE FOR ALL YOUR HELP!
Best Regards
lengoundry
Britton posted this at 17:08 — 23rd October 2005.
He has: 25 posts
Joined: Mar 2004
Yes, I've done it. I'd be glad to give you my thumbnail file and show you how to use it.
Britton posted this at 17:09 — 23rd October 2005.
He has: 25 posts
Joined: Mar 2004
PM me or instant message me at BrittonKeene
Busy posted this at 20:59 — 23rd October 2005.
He has: 6,151 posts
Joined: May 2001
The image would have to be loaded through GD to make a thumbnail, giving it a URL may work but thats basically hotlinking (sucking up someone elses bandwidth)
JeevesBond posted this at 12:07 — 24th October 2005.
He has: 3,956 posts
Joined: Jun 2002
Megan: http://www.boutell.com/gd/
So you give it an image, tell it to do stuff (like resize to 50 x 50) and it does it. Nice thing is that you can use it in a script, so uploaded files can be manipulated on the fly, which is what lengoundry's trying to do here.
Reading the blurb it's mainly used for drawing graphs and such, so my guess is it's used in a lot of stats packages.
a Padded Cell our articles site!
lengoundry posted this at 14:12 — 24th October 2005.
He has: 4 posts
Joined: Mar 2002
Hi to all
many thanks for all the reply's
here is how I get thumbnails via GD
All I would like to know is what code would I use
to make thumbnails of images hosted elsewhere
using GD.
THANKS AGAIN EVERYONE FOR YOUR HELP!
Best Regards
Len
############################
### make thumbnail using GD
my $base; my $dir; my $ext;
($base, $dir, $ext) = fileparse($form{'UPIMAGE1'});
my $srcimage;
my $maxheight = 75;
my $maxwidth = 75;
if ($base =~ /.+(\.jpg|\.jpeg)$/i) {
$srcimage = GD::Image->newFromJpeg("$config{'imagebase'}/$form{'UPIMAGE1'}");
}
if ($base =~ /.+\.gif$/i) {
$srcimage = GD::Image->newFromGif("$config{'imagebase'}/$form{'UPIMAGE1'}");
}
my ($srcW,$srcH) = $srcimage->getBounds();
my $wdiff = $srcW - $maxwidth;
my $hdiff = $srcH - $maxheight;
my $newH; my $newW; my$aspect;
##this maintains the aspect of the image
if ($wdiff > $hdiff) {
$newW = $maxwidth;
$aspect = ($newW/$srcW);
$newH = int($srcH * $aspect);
} else {
$newH = $maxheight;
$aspect = ($newH/$srcH);
$newW = int($srcW * $aspect);
}
my $newimage = new GD::Image($newW,$newH);
$newimage->copyResized($srcimage,0,0,0,0,$newW,$newH,$srcW,$srcH);
open(OUT, ">$config{'thumbbase'}/$base") || die "Cannot create thumbnail: $!\n";
binmode OUT;
print OUT $newimage->jpeg;
close OUT;
### End of Thumbnail creation
##############################
Busy posted this at 20:36 — 24th October 2005.
He has: 6,151 posts
Joined: May 2001
JeevesBond, GD is like image::mavick, does a lot more than graphs, can make images on the fly, like the security ones seen on forums but can change formats, crop, resize, add text, blur, sharpen, resize, rotate .... Is like a mini ifranview online
lengoundry, this part of the code wouldn't need to be touched, you'd just have to make sure $base, $dir and $ext had the right values, ie: ext was the file extension that is actually an image ... I don't believe you can do it as the code need ths image to resize, using just a link would cause all sorts of issues, security related as well. Did you email/pm Britton ?
lengoundry posted this at 10:06 — 25th October 2005.
He has: 4 posts
Joined: Mar 2002
Hi
Many thanks for your reply!
I know image magick can do this
but my host server only has GD
Did you email/pm Britton ?
I will do that now.
thanks again for your help!
Best Regards
Len
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.