function make_thumb($src,$dest,$desired_width)
    {
      $img = new Zubrag_image;

      // initialize
      $img->max_y = $desired_width;

      // generate thumbnail
      $img->GenerateThumbFile($src, $dest);
    }
Exemple #2
0
        }
        // Fill image with white background (255,255,255)
        $white = imagecolorallocate($ni, 255, 255, 255);
        imagefilledrectangle($ni, 0, 0, $this->max_x, $this->max_y, $white);
        // Create a new image from source file
        $im = $this->ImageCreateFromType($orig_img_type, $from_name);
        // Copy the palette from one image to another
        imagepalettecopy($ni, $im);
        // Copy and resize part of an image with resampling
        imagecopyresampled($ni, $im, 0, 0, 0, 0, $this->max_x, $this->max_y, $orig_x, $orig_y);
        // srcW, srcH
        // save thumb file
        $this->SaveImage($ni, $to_name);
        if ($temp) {
            unlink($tmpfname);
            // this removes the file
        }
    }
}
$img = new Zubrag_image();
// initialize
$img->max_x = $max_x;
$img->max_y = $max_y;
$img->cut_x = $cut_x;
$img->cut_y = $cut_y;
$img->quality = $image_quality;
$img->save_to_file = $save_to_file;
$img->image_type = $image_type;
// generate thumbnail
$img->GenerateThumbFile($images_folder . $from_name, $thumbs_folder . $to_name);
Exemple #3
0
<?

include('plugin.gallery.upload.php');

$img = new Zubrag_image;

// initialize
$img->max_x        = 150;

// generate thumbnail
$img->GenerateThumbFile('./../../media/images/testbild.jpg', './../../media/images/thumb_testbild.jpg');

?>
 public function createThumbs($from_name, $to_name, $max_x, $max_y)
 {
     ini_set('memory_limit', '-1');
     // include image processing code
     include 'image.class.php';
     $img = new Zubrag_image();
     // initialize
     $img->max_x = $max_x;
     $img->max_y = $max_y;
     $img->cut_x = 0;
     $img->cut_y = 0;
     $img->quality = 100;
     $img->save_to_file = true;
     $img->image_type = -1;
     $img->GenerateThumbFile($from_name, $to_name);
 }
             // $error = 1;
             // $message .= " * Please request admin to change the permission of 'portfolios' folder in the root to 777 <br>";
         }
     }
 } else {
     if ($mybusinessid == "") {
         if ($_FILES['artistphoto']['name'] == "") {
             $message .= " * Image  is required!" . "<br>";
             $error = 1;
         }
     }
 }
 if ($message == "") {
     if ($artistphotoname != "") {
         move_uploaded_file($_FILES['artistphoto']['tmp_name'], $artistphotodest);
         $img->GenerateThumbFile($artistphotodest, $artistphotodest_tmb, 150, 143);
     }
     if ($mybusinessid != "") {
         // Update
         $sql = "UPDATE " . $tableprefix . "mybusiness SET\n\t\t\t\tmybusinessdesc = '" . addslashes($txtArtistDescription) . "'";
         if ($artistphotoname != "") {
             $sql .= ", mybusinessimage = '" . addslashes($artistphotoname) . "'";
         }
         $sql .= " WHERE mybusinessid= '" . addslashes($mybusinessid) . "' AND artistid = '" . addslashes($artistid) . "' ";
         mysql_query($sql);
         $mybusinessid = "";
         $txtArtistDescription = "";
         $message = "Business information updated successfully!";
     } else {
         // Insert data to table
         $sql_insert = "INSERT INTO " . $tableprefix . "mybusiness (mybusinessdesc ,artistid ,mybusinessimage)\n\t\t\t\t\t\tVALUES('" . addslashes($txtArtistDescription) . "','" . addslashes($artistid) . "','" . addslashes($artistphotoname) . "')";
         $error = true;
     } else {
         if (file_exists($artistphotodest)) {
             $message .= " * Vendor Photo with the same name exists! Please rename the Vendor Photo and upload! " . "<br>";
             $error = true;
         }
     }
     if (!is_readable($portfoliodir) || !is_writable($portfoliodir) || !is_executable($portfoliodir)) {
         $error = true;
         // $message .= " * Please request admin to change the permission of 'portfolios' folder in the root to 777 <br>";
     }
 }
 if ($message == "") {
     if ($artistphotoname != "") {
         move_uploaded_file($_FILES['artistphoto']['tmp_name'], $artistphotodest);
         $img->GenerateThumbFile($artistphotodest, $artistphotodest, 120, 150);
     }
     $rs_qr = mysql_query("select * from " . $tableprefix . "artist_portfolios\twhere artist_id =" . $artistid);
     $resultrows = mysql_num_rows($rs_qr);
     if (isset($portfolioid) and $portfolioid != "") {
         $sql = "SELECT ap.* FROM " . $tableprefix . "artists a INNER JOIN " . $tableprefix . "artist_portfolios ap ON a.artist_id = ap.artist_id  WHERE a.artist_id = '" . addslashes($artistid) . "' AND ap.artist_portfolio_id = '" . addslashes($portfolioid) . "' ";
         $res = mysql_query($sql);
         if (mysql_num_rows($res) > 0) {
             $row = mysql_fetch_array($res);
             $txtArtistPhoto = $row["artist_photo"];
         }
     }
     // end portfolio id Check
     if ($resultrows > 0) {
         // Update port folio page if data exitsts
         $sql = "UPDATE " . $tableprefix . "artist_portfolios SET\n\t\t\t\tartist_description = '" . addslashes($txtArtistDescription) . "'";
Exemple #7
0
}
if (isset($_REQUEST['y'])) {
    $max_y = intval($_REQUEST['y']);
}
$full_path = $images_folder . $from_name;
if (!file_exists($images_folder)) {
    die('Images folder does not exist (update $images_folder in the script)');
}
if ($save_to_file && !file_exists($thumbs_folder)) {
    die('Thumbnails folder does not exist (update $thumbs_folder in the script)');
}
if (!file_exists($full_path)) {
    $from_name = 'blank-person.png';
}
// Allocate all necessary memory for the image.
// Special thanks to Alecos for providing the code.
ini_set('memory_limit', '-1');
// include image processing code
include 'image.class.php';
$img = new Zubrag_image();
// initialize
$img->max_x = $max_x;
$img->max_y = $max_y;
$img->cut_x = $cut_x;
$img->cut_y = $cut_y;
$img->quality = $image_quality;
$img->save_to_file = $save_to_file;
$img->image_type = $image_type;
// generate thumbnail
$img->GenerateThumbFile($images_folder . $from_name, '');