473,396 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
4 1458
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Roel Wuyts | last post by:
CALL FOR CONTRIBUTIONS International Workshop on Revival of Dynamic Languages http://pico.vub.ac.be/~wdmeuter/RDL04/index.html (at OOPSLA2004, Vancouver, British Columbia, Canada, October...
6
by: Materialised | last post by:
Hi Everyone, I apologise if this is covered in the FAQ, I did look, but nothing actually stood out to me as being relative to my subject. I want to create a 2 dimensional array, a 'array of...
3
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example...
3
by: rangermccoy | last post by:
Hello there, What are the best php/c libraries for handling media including images, video, and music? I would like to manipulate media dfiles, including watermarking, thumbnailing,...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
0
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab,...
3
by: philleep | last post by:
Hi, Someone told me that you can do auto thumbnailing in php. How? cheer, Philleep
5
by: bearophileHUGS | last post by:
I often use Python to write small programs, in the range of 50-500 lines of code. For example to process some bioinformatics data, perform some data munging, to apply a randomized optimization...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.