|
طلب فنكشن رفع + طبع الحقوق + اعادة تحجيم
السلام عليكم
باختصار محتاج فنكشن او غيره لتصغير الصور وطبع الحقوق استخدمت فنكشن
function createthumb($name,$filename,$new_w,$new_h){
$system=explode('.',$name);
if (preg_match('/jpg|jpeg/',$system[1])){
$src_img=imagecreatefromjpeg($name);
}
if (preg_match('/png/',$system[1])){
$src_img=imagecreatefrompng($name);
}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
if (preg_match("/png/",$system[1]))
{
imagepng($dst_img,$filename);
} else {
imagejpeg($dst_img,$filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
//============================
if(strstr($_FILES["file1"]["type"],"image"))
{
$a_img=$HTTP_POST_FILES['file1']['name'];
$ex1=strtolower(end(explode('.',$a_img)));
$splitedImageName=explode(".",$imgName);
$type=$splitedImageName[sizeof($splitedImageName)-1];
$imgName=time().".".$ex1;
$thumb =$_SERVER["DOCUMENT_ROOT"]."/shoot/images/upload/thumb/".$imgName;
$orignal =$_SERVER["DOCUMENT_ROOT"]."/shoot/images/upload/orignal/".$imgName;
$genuines =$_SERVER["DOCUMENT_ROOT"]."/shoot/images/upload/images/".$imgName;
copy($_FILES['file1']['tmp_name'], $thumb);
copy($_FILES['file1']['tmp_name'], $orignal);
copy($_FILES['file1']['tmp_name'], $genuines);
createthumb($thumb,$thumb,202,255);
createthumb($orignal,$orignal,700,625);
}
else{$message = "لم يتم استلام ملف لكي يتم رفعه";
}
لكن عيبه انه عند تصغير الصور تروح دقة الصورة مثال الصورة قبل الرفع ![]() بعد التصغير
1 إجابة
salamo alikom
try this class, i use it in all of my application its veru usefl and can do what youn looking for Download hope thats can help u بواسطة: chlieh 2 من 2 أشخاص وجدو هذه الاجابة مفيدة. هل وجدتها؟ نعم لا thanks ^^ |



هل رايت هذه المقالة "تصغير و قص الصور وقت الطلب فقط لاى حجم" اما اضافة الـwatermark تتم اثناء عملية الرفع
23 / أبريل / 2012 الساعة 19:51