PDA

View Full Version : resize & upload



mohsenshahab
شنبه 16 آبان 1388, 16:20 عصر
سلام من به دنبال راهی هستم که ابتدا فایل رو resize کنه و بعد فایل resize شده رو آپ کنه
چون این طور که من دیدم تو ci اول باید فایل رو آپ کنیم بعد فایل جدیدی رو بسازیم و resize کنیم

J.Masomi
چهارشنبه 16 دی 1388, 23:40 عصر
با سلام
من خودم دنبال این موضوع بودم که دیدم طبق معمول تو این سایت جوابی پیدا نمیشه.
خوب همه برنامه نوسیم دیگه:کف: و طاقت اینکه کسی بیشتر از ما بدونه را نداریم:عصبانی:
من کد زیر را پیدا کردم که تابع خوبی است.برای کار شما هم خوبه ولی باید بعد از آپلود فایل این کار را انجام بدی و بعد از resize فایل اصلی را با unlink() پاک کنی.

/* 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)
{

/* Get the dimensions of the source picture */
$picsize=getimagesize("$sourcefile");
$source_x = $picsize[0];
$source_y = $picsize[1];
$source_id = imageCreateFromJPEG("$sourcefile");
/* 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 */

imagejpeg ($target_id,"$targetfile",$jpegqual);
return true;
}

if(resizeToFile('images/2.jpg','570px',130,'5.jpg','50'))
echo 'created.<br><img src="5.jpg" alt="اخبار" />';
else
echo 'not!';

fafa_na
پنج شنبه 24 دی 1388, 11:05 صبح
كممممممممممممممممممك:گریه:
من كد zoom به زبان php ميخوام.فوري لطفا هر كس هر چي ميدون بگه.اگه فايلي هم داريد كه به دردم بخوره
اين ميلم:sharifysaftware@yahoo.com
مرسسسسسسسسسسسي:خجالت::خجال :

hidensoft
پنج شنبه 22 بهمن 1388, 09:58 صبح
برای zoom در تصویر باید از جاوا اسکریپت استفاده کنید دوست عزیز
سرور ساید و کلاینت ساید تفاوت های زیادی با هم دارند