Esempio n. 1
0
 public static function small($file)
 {
     require_once dirname(__FILE__) . '/../phpthumb/phpthumb.class.php';
     $basefile = new File($file);
     $basepath = File::a2r($file);
     $webimg = dirname($basepath) . "/" . $basefile->name . "_small." . $basefile->extension;
     list($x, $y) = getimagesize($file);
     if ($x <= 1200 && $y <= 1200) {
         return $file;
     }
     $path = File::r2a($webimg, Settings::$thumbs_dir);
     /// Create smaller image
     if (!file_exists($path) || filectime($file) > filectime($path)) {
         if (!file_exists(dirname($path))) {
             @mkdir(dirname($path), 0755, true);
         }
         $thumb = new phpthumb();
         $thumb->config_imagemagick_path = Settings::$imagemagick_path;
         $thumb->setSourceData(file_get_contents($file));
         $thumb->CalculateThumbnailDimensions();
         $thumb->w = 1200;
         $thumb->h = 1200;
         $thumb->q = Settings::$quality_small;
         if (File::Type($file) == 'Image' && Provider::get_orientation_degrees($file) != 0) {
             $thumb->SourceImageToGD();
             //$thumb->ra = Provider::get_orientation_degrees($file);
             $thumb->Rotate();
         }
         $thumb->GenerateThumbnail();
         $thumb->RenderToFile($path);
     }
     return $path;
 }
Esempio n. 2
0
// Note: this must be the actual binary data of the image, not a URL or filename
// see http://www.billy-corgan.com/blog/archive/000143.php for a brief tutorial on this section
//$SQLquery = 'SELECT `picture` FROM `products` WHERE (`id` = \''.mysql_escape_string(@$_GET['id']).'\')';
if (@$SQLquery) {
    // change this information to match your server
    $hostname = 'localhost';
    $username = '******';
    $password = '******';
    $database = 'database';
    if ($cid = @mysql_connect($hostname, $username, $password)) {
        if (@mysql_select_db($database, $cid)) {
            if ($result = @mysql_query($SQLquery, $cid)) {
                if ($row = @mysql_fetch_array($result)) {
                    mysql_free_result($result);
                    mysql_close($cid);
                    $phpthumb->setSourceData($row[0]);
                    unset($row);
                } else {
                    mysql_free_result($result);
                    mysql_close($cid);
                    $phpthumb->ErrorImage('no matching data in database.');
                    //$phpthumb->ErrorImage('no matching data in database. MySQL said: "'.mysql_error($cid).'"');
                }
            } else {
                mysql_close($cid);
                $phpthumb->ErrorImage('Error in MySQL query: "' . mysql_error($cid) . '"');
            }
        } else {
            mysql_close($cid);
            $phpthumb->ErrorImage('cannot select MySQL database: "' . mysql_error($cid) . '"');
        }