
03-19-2005, 05:06 AM
|
|
Web Hosting Master
|
|
Join Date: Sep 2000
Posts: 1,003
|
|
Feedback on PHP image script?
Hi:
I'm looking for some feedback on this PHP image optimizing script I just completed: http://webmasterpick.com/gifoptimize/ Please let me know if you find any bugs or other more serious issues (pm please when more appropriate). What about a certain features that you think are missing or would be useful?
Thanks,
|

03-19-2005, 12:09 PM
|
|
Web Hosting Guru
|
|
Join Date: Mar 2005
Posts: 290
|
|
Awesome script. 
|

03-19-2005, 05:38 PM
|
|
Web Hosting Master
|
|
Join Date: Sep 2000
Posts: 1,003
|
|
Thanks.  If anyone has feedback on bugs or potential security issues, please let me know as well.
|

03-19-2005, 05:56 PM
|
|
WHT Addict
|
|
Join Date: Apr 2004
Location: Port St Lucie, FL
Posts: 117
|
|
|

03-21-2005, 09:40 AM
|
|
Junior Guru Wannabe
|
|
Join Date: Feb 2005
Posts: 37
|
|
Nice.
Why not make another one in which you can resize it by percentage, number, best fit ratio, and resample it to a set quality? :-)
It's actually really. I just did one in fact for a client.
-Ben
__________________
Experience:
Photoshop CS3, Dreamweaver, Fireworks, Flash, HTML, Javascript, PHP/MySQL Database, CMS
|

03-21-2005, 09:50 AM
|
|
Junior Guru Wannabe
|
|
Join Date: Feb 2005
Posts: 37
|
|
This is my script. I had a little help from someone here on WHT. But all the calculations are mine.
PHP Code:
<?
/*==Image Resizer=====================================*/
/*This script currently does NOT support other formats*/
/*other than JPG or JPEG. Though, I made it for */
/*photos which should be in JPG format anyways. */
/*Basically, it will take the file uploaded, determine*/
/*which proportion is greater (width or height) and */
/*resize it to fit within the constraints given. */
/*====================================================*/
/*Notice the calculations.*/
function resizeToFile ($sourcefile, $max_x, $max_y, $targetfile, $jpegqual) {
/* Get the dimensions of the source picture */
$picsize=getimagesize("$sourcefile");
$source_x = $picsize[0];
$source_y = $picsize[1];
$source_id = imageCreateFromJPEG("$sourcefile");
/* Best fit image */
/*This is where the script checks for the greater ratio.*/
/*If you have an image resize script, this would be the */
/*section that determines the 'best fit' for a pair of */
/*constraints given. */
if(($source_x/$max_x) > ($source_y/$max_y))
{
$ratio = $source_x/$max_x;
$max_y=$source_y/$ratio;
}
else
{
$ratio = $source_y/$max_y;
$max_x=$source_x/$ratio;
}
/* Create image object */
$target_id=imagecreatetruecolor($max_x, $max_y);
/* Resize JPG */
$target_pic=imagecopyresampled($target_id,$source_id,0,0,0,0,$max_x,$max_y,$source_x,$source_y);
/* Create JPG */
imagejpeg ($target_id,"$targetfile",$jpegqual);
return true;
}
?>
__________________
Experience:
Photoshop CS3, Dreamweaver, Fireworks, Flash, HTML, Javascript, PHP/MySQL Database, CMS
|

03-21-2005, 03:41 PM
|
|
WHT Addict
|
|
Join Date: Feb 2005
Location: Seattle, Washington
Posts: 144
|
|
easybyte: hard to give feedback, especially on "bugs or potential security issues" as you request, if you do not post the PHP code to it.
nonetheless, looks cool, a nice idea, and useful 
|

03-21-2005, 04:08 PM
|
|
Community Guide
|
|
Join Date: Mar 2005
Location: England
Posts: 1,201
|
|
Looks good but I havent tried it out yet but I will probably need it soon so I bookmarked it.
|

03-21-2005, 04:50 PM
|
|
Web Hosting Master
|
|
Join Date: Sep 2000
Posts: 1,003
|
|
Currently I'm limiting image size to 100k, so you're getting that error (image is 140k). I'll probably double that limit depending on how it affects my server resources.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|