コード例 #1
0
 function __construct($image = false, $output = false)
 {
     // set up filters for this instance
     $this->filters = apply_filters('instagraph_filters', $this->filters);
     // set the parent class up
     if ($image && $output) {
         parent::__construct($image, $output);
     }
 }
コード例 #2
0
ファイル: wx.service.php プロジェクト: johen/mytmpcode
 /**
  * 响应客户消息
  */
 public function responseMsg()
 {
     //get post data, May be due to the different environments
     $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
     $message = '';
     //extract post data
     if (!empty($postStr)) {
         $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
         switch (strtolower($postObj->Event)) {
             case 'subscribe':
                 //订阅消息
                 $message = $this->_response_text($postObj, _FOCUS_MESSAGE);
                 break;
             case 'click':
                 //点击菜单消息
                 //根据用户点击内容分发
                 $content = trim($postObj->EventKey);
                 $postObj->Content = $content;
                 //去掉空格
                 if ($content !== '') {
                     $message = $this->_get_wx_content($postObj);
                 }
                 break;
             default:
                 switch (strtolower($postObj->MsgType)) {
                     case 'image':
                         //发送图片
                         $instagraph = Instagraph::factory();
                         //复制照片
                         $sPicKey = $instagraph->copyurl2data($postObj->PicUrl);
                         $sReturn = SHOWPICURL . "?pickey=" . $sPicKey;
                         $handle = pclose(popen(PHPBIN . ' show.php ' . $sPicKey . ' &', 'r'));
                         //                            $handle = popen('php show.php '.$sPicKey.' 2>&1', 'r');
                         //                            $read = fread($handle, 2096);
                         //                            echo $read;
                         //                            pclose($handle);
                         $aRespone = array(array('title' => $this->_wxConfig['wxshowmsg']['title'], 'description' => $this->_wxConfig['wxshowmsg']['description'], 'picUrl' => $this->_wxConfig['wxshowmsg']['picUrl'], 'url' => $sReturn));
                         $message = $this->_response_news($postObj, $aRespone);
                         //                            $message = $this->_response_text($postObj, $sReturn);
                         break;
                     default:
                         $content = trim($postObj->Content);
                         $postObj->Content = $content;
                         //去掉空格
                         //根据用户输入内容分发
                         if ($content !== '') {
                             $message = $this->_get_wx_content($postObj);
                         }
                         break;
                 }
                 break;
         }
     }
     echo $message;
 }
コード例 #3
0
ファイル: SiteController.php プロジェクト: aommiez/pla2gram
 public function actiongoPhotoFB()
 {
     ignore_user_abort(1);
     set_time_limit(0);
     $urlPhoto = $_POST['urlPhoto'];
     $f = $_POST['filter'];
     $capPhoto = $_POST['capPhoto'];
     Helper::debugConsole("post ok");
     $namePhoto = Helper::getLastPath($urlPhoto);
     $min_rand = rand(0, 1000);
     $max_rand = rand(100000000000, 10000000000000000);
     $name_file = rand($min_rand, $max_rand);
     //this part is for creating random name for image
     $ext = end(explode(".", $namePhoto));
     //gets extension
     $file = Yii::app()->request->baseUrl . "photo/" . $name_file . "." . $ext;
     // Save Photo From Facebook And Add Filter
     Helper::save_image($urlPhoto, $file);
     $filter = Instagraph::factory($file, $file);
     $filter->{$f}();
     Helper::debugConsole("Save Photo From Facebook And Add Filter ok");
     // 320 Show Preview
     $immid = new Imagick($file);
     if ($immid->getimagewidth() > 320) {
         $immid->thumbnailImage(320, null);
         $immid->writeImage(Yii::app()->request->baseUrl . "thumb/thumb320_" . $name_file . "." . $ext);
         $immid->destroy();
         chmod(Yii::app()->request->baseUrl . "thumb/thumb320_" . $name_file . "." . $ext, 0777);
     } else {
         $immid->writeImage(Yii::app()->request->baseUrl . "thumb/thumb320_" . $name_file . "." . $ext);
         $immid->destroy();
         chmod(Yii::app()->request->baseUrl . "thumb/thumb320_" . $name_file . "." . $ext, 0777);
     }
     Helper::debugConsole("320 Show Preview ok");
     // null x 230 show last upload
     $imlast = new Imagick($file);
     $imlast->thumbnailimage(null, 230);
     $imlast->writeImage(Yii::app()->request->baseUrl . "thumb/thumb230_" . $name_file . "." . $ext);
     $imlast->destroy();
     chmod(Yii::app()->request->baseUrl . "thumb/thumb230_" . $name_file . "." . $ext, 0777);
     Helper::debugConsole("null x 230 show last upload ok");
     // 130 x 110 thumbmail
     $im = new Imagick($file);
     $im->thumbnailImage(130, 110);
     $im->writeImage(Yii::app()->request->baseUrl . "thumb/thumb_" . $name_file . "." . $ext);
     chmod(Yii::app()->request->baseUrl . "thumb/thumb_" . $name_file . "." . $ext, 0777);
     $im->destroy();
     Helper::debugConsole("130 x 110 thumbmail ok");
     $photo = new Photo();
     $photo->link = $file;
     $photo->fbid = Yii::app()->facebook->getUser();
     $photo->ip = $_SERVER['REMOTE_ADDR'];
     Helper::debugConsole("set data ok");
     if ($photo->save()) {
         $id = $photo->id;
         $cr = "\n" . "http://www.pla2gram.com/?p=" . $id . "&theater=1";
         $capFB = $capPhoto . $cr;
         Helper::debugConsole("set fb ok");
         // Post to Facebook
         $args = array('message' => $capFB);
         $args['image'] = '@' . realpath($file);
         Yii::app()->facebook->api('/me/photos', 'post', $args);
         Helper::debugConsole("save fb ok");
         Helper::redir("/?p=" . $id, 0);
     } else {
         print_r($photo->getErrors());
     }
 }
コード例 #4
0
ファイル: index.php プロジェクト: rsteiner/instagraph
<?php

require '../bootstrap.php';
$output = NULL;
if (!empty($_GET['url']) and !empty($_GET['filter'])) {
    $filename = sha1(basename($_GET['url']));
    $filepath = ROOT . 'public/images/input/' . $filename . '.jpg';
    if (!file_exists($filepath)) {
        $retval = file_put_contents($filepath, file_get_contents($_GET['url']));
        if ($retval == false) {
            die('Unable to fetch image from given URL. Aborting.');
        }
    }
    $output = ROOT . 'public/images/output/' . $filename . '.jpg';
    $instagraph = new Instagraph();
    $instagraph->setInput($filepath);
    $instagraph->setOutput($output);
    $instagraph->process($_GET['filter']);
}
if (isset($_GET['__ajax']) or isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
    $output = str_replace(array('\\', str_replace('\\', '/', __DIR__)), array('/', ''), $output);
    header('Location: ' . $output, TRUE, 301);
    die;
}
require ROOT . 'public/template.php';
コード例 #5
0
ファイル: test.php プロジェクト: johen/mytmpcode
*/
//$sShowImgSrc = "data/65cf281093a3a9cf991c4024836ca61f.tan.output.jpg";
try {
    //    exec('whereis php', $sOut);
    //    var_dump($sOut);
    //    exec('/usr/bin/php -v', $sOut);
    //    var_dump($sOut);
    //        $sPicKey = "f939a6f396b8b609bdc631d268361e1d";
    //        $handle = popen('/usr/bin/php '.__DIR__.'/show.php '.$sPicKey.' &', 'r');
    //        $read = fread($handle, 2096);
    //        echo($read);
    //        pclose($handle);
    //    exit;
    $sPicKey = 'demo';
    $aOutput = array();
    $instagraph = Instagraph::factory();
    $instagraph->setImgPath($sPicKey);
    //    $instagraph->kelvin();
    //    $instagraph->gotham();
    //    $instagraph->watermask();
    $aOutput[] = $instagraph->neutrogena_shui();
    $aOutput[] = $instagraph->neutrogena_tou();
    $aOutput[] = $instagraph->neutrogena_tan();
    //    $instagraph->nashville();
    $sShowImgSrc = str_replace($_SERVER['DOCUMENT_ROOT'], "", $aOutput[array_rand($aOutput)]);
    $sShowImgSrc = str_replace("//", "/", $sShowImgSrc);
    var_dump("OK");
} catch (Exception $e) {
    echo $e->getMessage();
    die;
}
コード例 #6
0
ファイル: filter.php プロジェクト: radare/instagraph
<?php

require 'instagraph.php';
try {
    $filter = $_GET['filter'];
    if (!in_array($filter, array('lomo', 'nashville', 'kelvin', 'toaster', 'gotham', 'tilt_shift'))) {
        $filter = 'nashville';
    }
    // if method not in array, default it
    $instagraph = Instagraph::factory('input.jpg', 'output.jpg');
} catch (Exception $e) {
    echo $e->getMessage();
    die;
}
$instagraph->{$filter}();
// name of the filter from class
header('Location: index.html');
// redirect to index