467,212 Members | 1,185 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,212 developers. It's quick & easy.

dynamic thumbnailing ?

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
  • viewed: 1321
Share:
4 Replies
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
re: revious example code:
forgot to include a closing brace in all the excitement...

Jul 17 '05 #3
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
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.

Similar topics

6 posts views Thread by Materialised | last post: by
3 posts views Thread by Stephen Gennard | last post: by
reply views Thread by Pascal Costanza | last post: by
3 posts views Thread by philleep | last post: by
5 posts views Thread by bearophileHUGS@lycos.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.