|
|
#1 (permalink) |
|
Registered User
Seasoned Poster
Joined in Jun 2004
Lives in Tennessee, USA
Hosted on Pass56
32 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
|
Alternative to exec()?
Hi! I'm running a script on my site that grabs a picture and shrinks it to a certain size like this:
PHP Code:
I can find my way around PHP, but am kind of new to it -- is there another way I can resize the images without using exec()? Thanks! Jeff. |
|
|
|
|
|
#2 (permalink) | |
|
Surpass Fan
Comfy Contributor
Joined in Feb 2004
Lives in Norfolk, England
Hosted on Pass32
145 posts
Gave thanks: 16
Thanked 17 times
|
Quote:
I just came across your post, sorry if the reply is too late. In case you haven't found a solution or someone else stumbles onto this thread with a similar question, you might want to look at using the (PHP) GD image library. There is a tutorial here that looks like it could be useful for someone with PHP knowledge: http://www.phpit.net/article/image-m...-php-gd-part2/ Regards Jonathan
__________________
Server: Pass32 and dedicated server |
|
|
|
|
|
|
#3 (permalink) |
|
Senior Member
Super #1
Joined in Nov 2003
Lives in New Hampshire
|
Code:
$size = 150; //Desired width. Height will be scaled Automatically.
$quality = 70; //Desired Quality of Resized Image out of 100.
$pathtoimage = "/path/to/image.jpg"; Path or URL to the picture
$pathtonewimage = "/path/to/newimage.jpg"; Your PATH TO resized picture
$src = ImageCreateFromJPEG($pathtoimage);
if(imagesx($src)>$size)
{
$xsiz = $size;
}
else
{
$xsiz = imagesx($src);
}
$ysiz = (((imagesy($src))*($xsiz))/imagesx($src));
$thumbnew = imagecreatetruecolor($xsiz, $ysiz);
imagecopyresampled($thumbnew,$src,0,0,0,0,$xsiz,$ysiz,imagesx($src),imagesy($src));
imagejpeg($thumbnew, $pathtonewimage, $quality);
__________________
The Coding Blog - Follow along as we discover and discuss everything it takes to code an entire website, start to finish! [Latest Entry: 4/4/08 - Starting a Website] |
|
|
|