Esempio n. 1
0
 /**
  * Constructor
  *
  * This is the constructor for the Spaz_Thumb object. By passing
  * the URL to the constructor we add the url and submit a job on
  * the webthumb server.
  *
  * @param string $url  The URL to get the thumb about
  */
 public function __construct($url)
 {
     $this->webthumb = new Bluga_Webthumb();
     $this->webthumb->setApiKey(self::API_KEY);
     $this->job = $this->webthumb->addUrl($url, self::THUMB_SIZE, 1024, 768);
     $this->webthumb->submitRequests();
 }
Esempio n. 2
0
 /** Use bluga webthumb generate service **/
 public function blugaWebThumbs($fileNames, $urls, $user_id = '')
 {
     require_once BASEPATH . 'libraries/Bluga/Autoload.php';
     $postRequest = false;
     $apiKey = '0ead01a59d8f241798b9f8827871a365';
     $dir = $path = $this->config->item('csv_upload_path');
     if ($user_id != '' && !is_dir($dir)) {
         mkdir($dir, 0777);
         chmod($dir, 0777);
     }
     try {
         $webthumb = new Bluga_Webthumb();
         $webthumb->setApiKey($apiKey);
         $i = 0;
         $jobs = array();
         $count = 0;
         foreach ($urls as $url) {
             try {
                 if (!file_exists($dir . $fileNames[$i] . '.png')) {
                     //echo "File not exists if ".$dir.$fileNames[$i].'.png';
                     $j = $webthumb->addUrl($url['url'], 'large', 1200, 900, $url['width'], $url['height']);
                     $j->file = $fileNames[$i];
                     $jobs[$count++] = $j;
                     $postRequest = true;
                 } else {
                     //echo "File not exists else";
                 }
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
             $i++;
         }
         if ($postRequest) {
             $webthumb->submitRequests();
             while (!$webthumb->readyToDownload()) {
                 //@ob_flush();
                 //flush();
                 sleep(6);
                 //echo "<font color='red'>Checking Job Status For graph Thumb</font><br>\n";
                 $webthumb->checkJobStatus();
             }
             $webthumb->fetchAll($dir);
             foreach ($webthumb->failedJobs as $url => $job) {
                 echo "No job submitted for: {$url}\n";
             }
         }
         //echo "FILENAME : ".$fileNames[0];
         return $fileNames[0];
     } catch (Exception $e) {
     }
 }
<pre>
<?php 
// bring in your configuration, api yet etc
require_once 'config.php';
ini_set('max_execution_time', 90);
$url = 'http://webthumb.bluga.net/';
try {
    $webthumb = new Bluga_Webthumb();
    $webthumb->setApiKey($APIKEY);
    $job = $webthumb->addUrl($url, 'medium2', 1024, 768);
    $webthumb->submitRequests();
    while (!$webthumb->readyToDownload()) {
        sleep(5);
        echo "Checking Job Status\n";
        $webthumb->checkJobStatus();
    }
    // while (!$webthumb->ready_to_download())
    $webthumb->fetchToFile($job);
    echo '<img src="' . $job->status->id . '.jpg' . '" /><br />';
} catch (Exception $e) {
    var_dump($e->getMessage());
}
?>

</pre>