By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,543 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,543 IT Pros & Developers. It's quick & easy.

dynamic thumbnailing ?

P: n/a
Need recomendation for script that would dynamicly create thumbnails from
pictures in certain directory, and automaticly genreate link to original
pictures...

Tuts are also welcom...

TNX.

------
www.podvodni-svijet.com

"Half-brother in blood,
full brother in heart will I be.
Thou shalt lead and I will follow.
May no new grief divide us."

Valar morghulis!
--
Remove all FAKEs when replying to mail !

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
look for some php photo-album software and review their source-code. I
worked it out by reading the php manual (image functions).

here's a function I wrote some time ago (for a photo album program of my
own). It tries to use a function called imageCopyResampled() but falls
back to imageCopyResized(). The newer function imageCopyResampled()
gives better quality but not all version of GD PHP modules have it.

You will have to modify this function as it was designed for my app. The
main param you are interested in is $intSize which represents the
maximum length of the longest side you want the thumbnail to be.

function createThumbnail($id,$idSrcImg,$intSize) {

$uriSrcDir = "../albums".$id."/";
$uriSrcImg = $uriSrcDir.$idSrcImg;
$uriThmImg = $uriSrcDir."_thumbs/".$idSrcImg;

$imgSrc=imagecreatefromjpeg($uriSrcImg);

$intSrcH = ImageSY($imgSrc);
$intSrcW = ImageSX($imgSrc);
if($intSrcH == $intSrcW) {
$intHeight = $intWidth = $intSize;
}
elseif($intSrcH > $intSrcW) {
$intHeight = $intSize;
$intWidth = ceil(($intSrcW/$intSrcH) * $intSize);
}
else {
$intWidth = $intSize;
$intHeight = ceil(($intSrcH/$intSrcW) * $intSize);
}

$imgThm=imagecreate($intWidth,$intHeight);

if(
!@imageCopyResampled(
$imgThm,
$imgSrc,
0,
0,
0,
0,
$intWidth,
$intHeight,
$intSrcW,
$intSrcH
)
) {
imageCopyResized(
$imgThm,
$imgSrc,
0,
0,
0,
0,
$intWidth,
$intHeight,
$intSrcW,
$intSrcH
);
}
Jul 17 '05 #2

P: n/a
re: revious example code:
forgot to include a closing brace in all the excitement...

Jul 17 '05 #3

P: n/a
Tnx. I will take a look at your code and refer to manual, im sure I'l manage
something..

Cheers....

------
www.podvodni-svijet.com

"Half-brother in blood,
full brother in heart will I be.
Thou shalt lead and I will follow.
May no new grief divide us."

Valar morghulis!
--
Remove all FAKEs when replying to mail !

Terence natipkase:
re: revious example code:
forgot to include a closing brace in all the excitement...

Jul 17 '05 #4

P: n/a
http://www.php.net/image

but i found it easier to use ImageMagick's convert tool, called via an
exec() in my thumbnailing script.
..: DeVa :. wrote:
Need recomendation for script that would dynamicly create thumbnails from
pictures in certain directory, and automaticly genreate link to original
pictures...

Tuts are also welcom...

TNX.

------
www.podvodni-svijet.com

"Half-brother in blood,
full brother in heart will I be.
Thou shalt lead and I will follow.
May no new grief divide us."

Valar morghulis!
--
Remove all FAKEs when replying to mail !


Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.