Jump to content

Recommended Posts

so I'm working in a function that will upload a file is is 600px wide to a directory, now if the picture is greater than 600 i want it to make it 600 before uploading to the directory, after is uploaded i want it to make it a thumbnail. 150pxwide.. how can i best good about this with out creating 2 functions?

this is what i have right now.. how can i fix this to make it what i want?

function MakeItFit($picName,$galId,$tmpPath,$save,$descrive,$reSize){
//RENAME THE FOTO
$remove=strstr($picName,'.');
$rand = mt_rand(0, 32);
$number = md5($rand . time()).$remove;
//Image width and height
list($widthx,$heighty)=getimagesize($picture);
//creating the make it fit picture for 600 width
$srcImg=imagecreatefromjpeg("$tmpPath");
$ratio=$reSize/$widthx;
$thumbHeight=$heighty*$ratio;
$thumbImg=imagecreatetruecolor($resize,$thumbHeight);
imagecopyresized($thumbImg,$srcImg,0,0,0,0,$resize,$thumbHeight,imagesx($srcImg),imagesy($srcImg));
imagejpeg($thumbImg,"$save/$number",100);

//GETTING THE THUMBNAIL READY
$getFixed="$save/$number";
if($getFixed){
list($widthT,$heightT)=getimagesize($getFixed);
$path=$getFixed;
$thumb=150;
$srcThumb=imagecreatefromjpeg($path);
$ratioT=$thumb/$widthT;
$thumbheight=$heightT*$ratioT;
$thumbTmg=imagecreatetruecolor($thumb,$thumbheight);
imagecopyresized($thumbTmg,$srcThumb,0,0,0,0,$thumb,$thumbheight,imagesx($srcThumb),imagesy($srcThumb));
imagejpeg($thumbTmg,"$save/tn_$number",100);
}
}

Link to comment
https://forums.phpfreaks.com/topic/54634-uploading-function/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.