النتائج 1 إلى 4 من 4

الموضوع: [Function] تصغير الصور

  1. #1
    عضو نشيط جدا
    تاريخ التسجيل
    May 2007
    المشاركات
    309

    [Function] تصغير الصور



    السلام عليكم ورحمة الله وبركاته
    كيف حالكم اليوم
    انتهيت الان من برمجت Function تصغير الصور
    المبرمج Bruce ->
    الفنكشن كامل
    كود PHP:
    // Resize image By Bruce - E-mail:prof.bruce@yahoo.it
      
    function  resizeimg($img,$hight=50,$with=50){
         
    $image          = @getimagesize($img);
      if(
    $image[0] > $with || $image[1] > $hight){
         
    $imgwith $with;
         
    $imghight $hight;
      }else{
         
    $imgwith $image[0];
         
    $imghight $image[1];
      }
         return 
    "<img src=$img width=$imgwith height=$imghight > ";
      } 
    طريقة الاستدعاء
    كود PHP:
    $posts_row['image']  = resizeimg($posts_row['image'],100,100); 
    في حالة عدم تعين قيمة تصبح 50 و50 كقيمة افتراضية
    انتظر ردودكم
    سلامات







  2. #2
    عضو شرف
    تاريخ التسجيل
    Apr 2002
    المشاركات
    1,379


    دالة جيده , لكن هذا ليس تصغير حقيقي للصوره انما تصغير عند عرض الصوره في الصفحة .
    عليك استخدام دوال بي اتش بي لتعامل مع الصور وايضا تصغيرها , ولو يكون عملية تحديد تصغيرالصور بالنسبه المئويه سيكون افضل .





    __________________
    ضيف الله العتيبي مبرمج حر و مهندس معتمد من زيند (ZCE)
    الاتصال: daif@daif.net او جوال: 0556639884
    الخدمات: تقديم استشارات برمجيه, تطوير بوابات/خدمات إلكترونيه للقطاع العام او الخاص .

  3. #3
    عضو شرف
    تاريخ التسجيل
    May 2007
    المشاركات
    1,647


    جزاك الله خيراً ...

    كلام الأخ daif سليم ... تفضل هذي دالة مع تطبيقها :
    كود PHP:
    <?
    $source_file
    ="http://localhost/test/x.jpg";
    $destination_file="http://localhost/test/";
    $max_dimension=200;
    create_thumbnail$source_file$destination_file$max_dimension);
    function 
    create_thumbnail$source_file$destination_file$max_dimension)
    {
        list(
    $img_width,$img_height) = getimagesize($source_file); // Get the original dimentions
        
    $aspect_ratio $img_width $img_height;
        if ( (
    $img_width $max_dimension) || ($img_height $max_dimension) ) // If either dimension is too big...
        
    {
            if ( 
    $img_width $img_height // For wide images...
            
    {
                
    $new_width $max_dimension;
                
    $new_height $new_width $aspect_ratio;
            }
            elseif ( 
    $img_width $img_height // For tall images...
            
    {
                
    $new_height $max_dimension;
                
    $new_width $new_height $aspect_ratio;
            }
            elseif ( 
    $img_width == $img_height // For square images...
            
    {
                
    $new_width $max_dimension;
                
    $new_height $max_dimension;
            }
            else { echo 
    "Error reading image size."; return FALSE; }
        }
        else { 
    $new_width $img_width$new_height $img_height; } // If it's already smaller, don't change the size.
        // Make sure these are integers.
        
    $new_width intval($new_width);
        
    $new_height intval($new_height);
        
    $thumbnail imagecreatetruecolor($new_width,$new_height); // Creates a new image in memory.
        // The following block retrieves the source file.  It assumes the filename extensions match the file's format.
        
    if ( strpos($source_file,".gif") ) { $img_source imagecreatefromgif($source_file); }
        if ( (
    strpos($source_file,".jpg")) || (strpos($source_file,".jpeg")) )
        { 
    $img_source imagecreatefromjpeg($source_file); }
        if ( 
    strpos($source_file,".bmp") ) { $img_source imagecreatefromwbmp($source_file); }
        if ( 
    strpos($source_file,".png") ) { $img_source imagecreatefrompng($source_file); }
        
    // Here we resample and create the new jpeg.
        
    imagecopyresampled($thumbnail$img_source0000$new_width$new_height$img_width$img_height);
        
    imagejpeg$thumbnail$destination_file100 );
        
    // Finally, we destroy the two images in memory.
        
    imagedestroy($img_source);
        
    imagedestroy($thumbnail);
    }
    ?>
    تحياتي، أشرف السمهوري






  4. #4
    عضو نشيط جدا
    تاريخ التسجيل
    May 2007
    المشاركات
    309


    عزيزي daif شكرا لمرورك الكريم
    انا طبقت الدالة للتصغير عند الاخراج فقط يعني عند الضغط عليها تصبح بحجمها الطبيعي ولااقصد التصغير الحقيقي لها
    كود PHP:
         return "<img src=$img width=$imgwith height=$imghight > "
    لتصبح
    كود PHP:
         return "<a href=$img title=اضغط علي الصورة لرؤيتها بحجمها الحقيقي ><img src=$img width=$imgwith height=$imghight ><br /> اضغط علي الصورة لرؤيتها بحجمها الحقيقي</a> "

    أشرف السمهوريشكرا دالة جميلة فعلا
    سلامات










ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •  

أضف موقعك هنا| اخبار السيارات | حراج | شقق للايجار في الكويت | بيوت للبيع في الكويت | دليل الكويت العقاري | مقروء | شركة كشف تسربات المياه | شركة عزل اسطح بالرياض | عزل فوم بالرياض| عزل اسطح بالرياض | كشف تسربات المياة بالرياض | شركة عزل اسطح بالرياض