Ask a Question related to PHP Development, Design and Development.
-
W. Paulisse #1
thumbnails with php
hy all,
i am complety new to GD and i must have a code within 2 days that does the
following for me
- Upload an image (jpg / png / gif) and save it on the server.
- Create an thumbnail of that image with a width and height of 100
- save the thumbnail on the server aswell
Can someone please help me on this or could give me a url with a good and
quick explanation how to handle GD?
Thx in advance,
wouter
W. Paulisse Guest
-
Add Dates To Thumbnails
Hello, I am fairly new to acrobat and have made a long pdf containing weekly reports by managers. Everything is fine except I want the page numbers... -
Thumbnails
What a helpful person cheesefood is.......prat!!! Ifv your thumbnails were saved in an earlier version of PS they may not open so you will need to... -
Illustrator thumbnails Win YES and illustrator thumbnails Mac NO?
Y have 2 different version Adobe Creative Suite one for windows, and one for MacOS X. The probem is: and Illustrator CS Mac the illustrator file... -
Illustrator thumbnails Win YES and illustrator thumbnails Mac NO? thumbnails thumbnails Illustr
Y have 2 different version Adobe Creative Suite one for windows, and one for MacOS X. The probem is: and Illustrator CS Mac the illustrator file... -
Hot To: Create thumbnails?
I am using the Dreamweaver 6.1 Studio on WinXP. This includes version 6 of Fireworks. If I have a huge JPG image, I am trying to figure out how... -
Janwillem Borleffs #2
Re: thumbnails with php
"W. Paulisse" <ihate@spam.nl> schreef in bericht
news:3f5589ef$0$49106$e4fe514c@news.xs4all.nl...[url]http://www.php.net/gd[/url]>
> Can someone please help me on this or could give me a url with a good and
> quick explanation how to handle GD?
>
Read it thouroughly and look ate the examples. I have prepared a quick and
dirty demo for you at the following location:
[url]http://www.jwscripts.com/playground/thumb.php[/url]
Just copy this into a local file and adjust the $path variable to suit your
environment.
JW
Janwillem Borleffs Guest
-
matty #3
Re: thumbnails with php
W. Paulisse wrote:
I have a script that will do this, but not for free!> hy all,
>
> i am complety new to GD and i must have a code within 2 days that does the
> following for me
>
> - Upload an image (jpg / png / gif) and save it on the server.
> - Create an thumbnail of that image with a width and height of 100
> - save the thumbnail on the server aswell
>
> Can someone please help me on this or could give me a url with a good and
> quick explanation how to handle GD?
>
> Thx in advance,
> wouter
It's not bad though - it'll handle jpeg and png files, let you resize to an
arbitrary size, add a text overlay (if you want), automatically create landscape/
protrait thumbs according to source image size (if wanted), and save the file under
a unique name on the server...
If you'd like to license it, let me know!
Matt
matty Guest
-
Martin Tollefsen #4
Re: thumbnails with php
W. Paulisse wrote:
Guide on how to create your own in minutes (!?):> i am complety new to GD and i must have a code within 2 days that
> does the following for me
>
> - Upload an image (jpg / png / gif) and save it on the server.
> - Create an thumbnail of that image with a width and height of 100
> - save the thumbnail on the server aswell
>
> Can someone please help me on this or could give me a url with a good
> and quick explanation how to handle GD?
[url]http://www.sitepoint.com/article/1195/2[/url]
Martin Tollefsen Guest
-
John Murtari #5
Re: thumbnails with php
"W. Paulisse" <ihate@spam.nl> writes:
Here are two function that do part of what you want:> hy all,
>
> i am complety new to GD and i must have a code within 2 days that does the
> following for me
>
> - Upload an image (jpg / png / gif) and save it on the server.
> - Create an thumbnail of that image with a width and height of 100
> - save the thumbnail on the server aswell
>
> Can someone please help me on this or could give me a url with a good and
> quick explanation how to handle GD?
>
# Function CreateThumbnail - creates the thumbnail version
# of a photo at a fixed size (81 high and correct width)
# INPUT - sourcefile name, targetfile name (thumbnail)
# OUTPUTS - new file in targetfile location
# RETURNS - 0 on success, message otherwise
#
function CreateThumbnail ($sourcefile, $targetfile) {
$desiredY = 81;
// Get the dimensions of the source picture
$picsize=getimagesize("$sourcefile");
if ($picsize == false) { // failed
return("Could not get size on picture $sourcefile");
}
$source_x = $picsize[0];
$source_y = $picsize[1];
$ratio = $desiredY / $source_y;
$newX = (int) ($ratio * $source_x);
$newY = (int) ($ratio * $source_y);
if ($msg = ResizeToFile($sourcefile, $newX, $newY, $targetfile)) {
return("Resize failed to targetfile: $targetfile ($msg)");
}
return(0);
}
/* Function: resizeToFile resizes a picture and writes it to the harddisk
*
* $sourcefile = the filename of the picture that is going to be resized
* $dest_x = X-Size of the target picture in pixels
* $dest_y = Y-Size of the target picture in pixels
* $targetfile = The name under which the resized picture will be stored
* $jpegqual = The Compression-Rate that is to be used
*/
function ResizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual=60)
{
/* Get the dimensions of the source picture */
$picsize=getimagesize("$sourcefile");
if ($picsize == false) {
return("Could not get size on file: $sourcefile\n");
}
$source_x = $picsize[0];
$source_y = $picsize[1];
$source_id = imageCreateFromJPEG("$sourcefile");
if (! $source_id) {
return("Could not create image from jpeg file: $sourcefile\n");
}
/* Create a new image object (not neccessarily true colour) */
$target_id=imagecreatetruecolor($dest_x, $dest_y);
/* resize the original picture and copy it into the just created image
object. Because of the lack of space I had to wrap the parameters to
several lines. I recommend putting them in one line in order keep your
code clean and readable
*/
$target_pic=imagecopyresampled($target_id,$source_ id,
0,0,0,0,
$dest_x,$dest_y,
$source_x,$source_y);
/* Create a jpeg with the quality of "$jpegqual" out of the
image object "$target_pic".
This will be saved as $targetfile */
$stat = imagejpeg ($target_id,"$targetfile" ,$jpegqual);
if (! $stat) {
return("Failed to create new image file: $targetfile");
}
return 0;
} // end function ResizeToFile
Hope this helps!
--
John
__________________________________________________ _________________
John Murtari Software Workshop Inc.
[email]jmurtari@thebook.com[/email] 315.635-1968(x-211) "TheBook.Com" (TM)
[url]http://www.thebook.com/[/url]
John Murtari Guest



Reply With Quote

