当前位置: 首页>>代码示例>>PHP>>正文


PHP media_resize_image函数代码示例

本文整理汇总了PHP中media_resize_image函数的典型用法代码示例。如果您正苦于以下问题:PHP media_resize_image函数的具体用法?PHP media_resize_image怎么用?PHP media_resize_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了media_resize_image函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: header

        header('HTTP/1.0 ' . $data['status'] . ' ' . $data['statusmessage']);
    }
    // die on errors
    if ($data['status'] > 203) {
        print $data['statusmessage'];
        exit;
    }
}
$evt->advise_after();
unset($evt);
//handle image resizing/cropping
if (substr($MIME, 0, 5) == 'image' && $WIDTH) {
    if ($HEIGHT) {
        $data['file'] = $FILE = media_crop_image($data['file'], $EXT, $WIDTH, $HEIGHT);
    } else {
        $data['file'] = $FILE = media_resize_image($data['file'], $EXT, $WIDTH, $HEIGHT);
    }
}
// finally send the file to the client
$evt = new Doku_Event('MEDIA_SENDFILE', $data);
if ($evt->advise_before()) {
    sendFile($data['file'], $data['mime'], $data['download'], $data['cache']);
}
// Do something after the download finished.
$evt->advise_after();
/* ------------------------------------------------------------------------ */
/**
 * Set headers and send the file to the client
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @author Ben Coburn <btcoburn@silicodon.net>
开发者ID:rezlemic,项目名称:dokuwiki-jQuery,代码行数:31,代码来源:fetch.php

示例2: _getImage

 /**
  * Override the mpdf _getImage function
  *
  * This function takes care of gathering the image data from HTTP or
  * local files before passing the data back to mpdf's original function
  * making sure that only cached file paths are passed to mpdf. It also
  * takes care of checking image ACls.
  */
 function _getImage(&$file, $firsttime = true, $allowvector = true, $orig_srcpath = false)
 {
     global $conf;
     // build regex to parse URL back to media info
     $re = preg_quote(ml('xxx123yyy', '', true, '&', true), '/');
     $re = str_replace('xxx123yyy', '([^&\\?]*)', $re);
     // extract the real media from a fetch.php uri and determine mime
     if (preg_match("/^{$re}/", $file, $m) || preg_match('/[&\\?]media=([^&\\?]*)/', $file, $m)) {
         $media = rawurldecode($m[1]);
         list($ext, $mime) = mimetype($media);
     } else {
         list($ext, $mime) = mimetype($file);
     }
     // local files
     $local = '';
     if (substr($file, 0, 9) == 'dw2pdf://') {
         // support local files passed from plugins
         $local = substr($file, 9);
     } elseif (!preg_match('/(\\.php|\\?)/', $file)) {
         $re = preg_quote(DOKU_URL, '/');
         // directly access local files instead of using HTTP, skip dynamic content
         $local = preg_replace("/^{$re}/i", DOKU_INC, $file);
     }
     if (substr($mime, 0, 6) == 'image/') {
         if (!empty($media)) {
             // any size restrictions?
             $w = $h = 0;
             if (preg_match('/[\\?&]w=(\\d+)/', $file, $m)) {
                 $w = $m[1];
             }
             if (preg_match('/[\\?&]h=(\\d+)/', $file, $m)) {
                 $h = $m[1];
             }
             if (media_isexternal($media)) {
                 $local = media_get_from_URL($media, $ext, -1);
                 if (!$local) {
                     $local = $media;
                 }
                 // let mpdf try again
             } else {
                 $media = cleanID($media);
                 //check permissions (namespace only)
                 if (auth_quickaclcheck(getNS($media) . ':X') < AUTH_READ) {
                     $file = '';
                 }
                 $local = mediaFN($media);
             }
             //handle image resizing/cropping
             if ($w && file_exists($local)) {
                 if ($h) {
                     $local = media_crop_image($local, $ext, $w, $h);
                 } else {
                     $local = media_resize_image($local, $ext, $w, $h);
                 }
             }
         } elseif (media_isexternal($file)) {
             // fixed external URLs
             $local = media_get_from_URL($file, $ext, $conf['cachetime']);
         }
         if ($local) {
             $file = $local;
             $orig_srcpath = $local;
         }
     }
     return parent::_getImage($file, $firsttime, $allowvector, $orig_srcpath);
 }
开发者ID:a-gundy,项目名称:dokuwiki-plugin-dw2pdf,代码行数:74,代码来源:DokuPDF.class.php

示例3: _imgfile

 /**
  * Return path to the rendered image on our local system
  * Note this is also called by img.php
  */
 function _imgfile($data)
 {
     $cache = $this->_cachename($data, 'png');
     // create the file if needed
     if (!file_exists($cache)) {
         $in = $this->_cachename($data, 'txt');
         if ($this->getConf('render_local') == '0' && $this->getConf('remote_url')) {
             $ok = $this->_remote($data, $in, $cache);
         } else {
             if ($this->getConf('render_local') == '1' && $this->getConf('java')) {
                 $ok = $this->_local($data, $in, $cache);
             } else {
                 return false;
             }
         }
         if (!$ok) {
             return false;
         }
         clearstatcache();
     }
     if ($data['width'] && $data['percent'] != '%') {
         $cache = media_resize_image($cache, 'png', $data['width'], $data['height']);
     }
     return file_exists($cache) ? $cache : false;
 }
开发者ID:derron,项目名称:dokuwiki_plantuml,代码行数:29,代码来源:syntax.php

示例4: _imgfile

 /**
  * Return path to the rendered image on our local system
  */
 function _imgfile($id, $data, $secondTry = false)
 {
     $cache = $this->_cachename($data, 'png');
     // create the file if needed
     if (!file_exists($cache)) {
         $in = $this->_cachename($data, 'txt');
         // If this is nt yet here, force geting instructions and writing the thing back.
         if ($secondTry != true && !file_exists($in)) {
             p_get_instructions(io_readFile(wikiFN($id)));
             return $this->_imgfile($id, $data, true);
         }
         if ($this->getConf('java')) {
             $ok = $this->_run($data, $in, $cache);
         } else {
             $ok = $this->_remote($data, $in, $cache);
         }
         if (!$ok) {
             return false;
         }
         clearstatcache();
     }
     // resized version
     if ($data['width']) {
         $cache = media_resize_image($cache, 'png', $data['width'], $data['height']);
     }
     // something went wrong, we're missing the file
     if (!file_exists($cache)) {
         return false;
     }
     return $cache;
 }
开发者ID:rztuc,项目名称:dokuwiki-plugin-ditaa,代码行数:34,代码来源:syntax.php

示例5: media_crop_image

/**
 * Crops the given image to the wanted ratio, then calls media_resize_image to scale it
 * to the wanted size
 *
 * Crops are centered horizontally but prefer the upper third of an vertical
 * image because most pics are more interesting in that area (rule of thirds)
 *
 * @author  Andreas Gohr <andi@splitbrain.org>
 */
function media_crop_image($file, $ext, $w, $h = 0)
{
    global $conf;
    if (!$h) {
        $h = $w;
    }
    $info = @getimagesize($file);
    //get original size
    if ($info == false) {
        return $file;
    }
    // that's no image - it's a spaceship!
    // calculate crop size
    $fr = $info[0] / $info[1];
    $tr = $w / $h;
    if ($tr >= 1) {
        if ($tr > $fr) {
            $cw = $info[0];
            $ch = (int) $info[0] / $tr;
        } else {
            $cw = (int) $info[1] * $tr;
            $ch = $info[1];
        }
    } else {
        if ($tr < $fr) {
            $cw = (int) $info[1] * $tr;
            $ch = $info[1];
        } else {
            $cw = $info[0];
            $ch = (int) $info[0] / $tr;
        }
    }
    // calculate crop offset
    $cx = (int) ($info[0] - $cw) / 2;
    $cy = (int) ($info[1] - $ch) / 3;
    //cache
    $local = getCacheName($file, '.media.' . $cw . 'x' . $ch . '.crop.' . $ext);
    $mtime = @filemtime($local);
    // 0 if not exists
    if ($mtime > @filemtime($file) || media_crop_imageIM($ext, $file, $info[0], $info[1], $local, $cw, $ch, $cx, $cy) || media_resize_imageGD($ext, $file, $cw, $ch, $local, $cw, $ch, $cx, $cy)) {
        if ($conf['fperm']) {
            chmod($local, $conf['fperm']);
        }
        return media_resize_image($local, $ext, $w, $h);
    }
    //still here? cropping failed
    return media_resize_image($file, $ext, $w, $h);
}
开发者ID:nblock,项目名称:dokuwiki,代码行数:57,代码来源:media.php

示例6: media_crop_image

/**
 * Crops the given image to the wanted ratio, then calls media_resize_image to scale it
 * to the wanted size
 *
 * Crops are centered horizontally but prefer the upper third of an vertical
 * image because most pics are more interesting in that area (rule of thirds)
 *
 * @author  Andreas Gohr <andi@splitbrain.org>
 */
function media_crop_image($file, $ext, $w, $h = 0)
{
    global $conf;
    if (!$h) {
        $h = $w;
    }
    $info = @getimagesize($file);
    //get original size
    if ($info == false) {
        return $file;
    }
    // that's no image - it's a spaceship!
    // calculate crop size
    $fr = $info[0] / $info[1];
    $tr = $w / $h;
    // check if the crop can be handled completely by resize,
    // i.e. the specified width & height match the aspect ratio of the source image
    if ($w == round($h * $fr)) {
        return media_resize_image($file, $ext, $w);
    }
    if ($tr >= 1) {
        if ($tr > $fr) {
            $cw = $info[0];
            $ch = (int) ($info[0] / $tr);
        } else {
            $cw = (int) ($info[1] * $tr);
            $ch = $info[1];
        }
    } else {
        if ($tr < $fr) {
            $cw = (int) ($info[1] * $tr);
            $ch = $info[1];
        } else {
            $cw = $info[0];
            $ch = (int) ($info[0] / $tr);
        }
    }
    // calculate crop offset
    $cx = (int) (($info[0] - $cw) / 2);
    $cy = (int) (($info[1] - $ch) / 3);
    //cache
    $local = getCacheName($file, '.media.' . $cw . 'x' . $ch . '.crop.' . $ext);
    $mtime = @filemtime($local);
    // 0 if not exists
    if ($mtime > @filemtime($file) || media_crop_imageIM($ext, $file, $info[0], $info[1], $local, $cw, $ch, $cx, $cy) || media_resize_imageGD($ext, $file, $cw, $ch, $local, $cw, $ch, $cx, $cy)) {
        if (!empty($conf['fperm'])) {
            @chmod($local, $conf['fperm']);
        }
        return media_resize_image($local, $ext, $w, $h);
    }
    //still here? cropping failed
    return media_resize_image($file, $ext, $w, $h);
}
开发者ID:yjliugit,项目名称:dokuwiki,代码行数:62,代码来源:media.php

示例7: _imgfile

 /**
  * Return path to the rendered image on our local system
  *
  * @param string $md5 MD5 of the input data, used to identify the cache files
  * @return false|string path to file or fals on error
  */
 public function _imgfile($md5)
 {
     $file_cfg = getCacheName($md5, '.ditaa.cfg');
     // configs
     $file_txt = getCacheName($md5, '.ditaa.txt');
     // input
     $file_png = getCacheName($md5, '.ditaa.png');
     // ouput
     if (!file_exists($file_cfg) || !file_exists($file_txt)) {
         return false;
     }
     $data = unserialize(io_readFile($file_cfg, false));
     // file does not exist or is outdated
     if (@filemtime($file_png) < filemtime($file_cfg)) {
         if ($this->getConf('java')) {
             $ok = $this->_runJava($data, $file_txt, $file_png);
         } else {
             $ok = $this->_runGo($data, $file_txt, $file_png);
             #$ok = $this->_remote($data, $in, $cache);
         }
         if (!$ok) {
             return false;
         }
         clearstatcache($file_png);
     }
     // resized version
     if ($data['width']) {
         $file_png = media_resize_image($file_png, 'png', $data['width'], $data['height']);
     }
     // something went wrong, we're missing the file
     if (!file_exists($file_png)) {
         return false;
     }
     return $file_png;
 }
开发者ID:splitbrain,项目名称:dokuwiki-plugin-ditaa,代码行数:41,代码来源:syntax.php

示例8: _imgfile

 /**
  * Return path to the rendered image on our local system
  */
 function _imgfile($data)
 {
     $cache = $this->_cachename($data, 'png');
     // create the file if needed
     if (!file_exists($cache)) {
         $in = $this->_cachename($data, 'txt');
         if ($this->getConf('path')) {
             $ok = $this->_run($data, $in, $cache);
         } else {
             $ok = $this->_remote($data, $in, $cache);
         }
         if (!$ok) {
             return false;
         }
         clearstatcache();
     }
     // resized version
     if ($data['width']) {
         $cache = media_resize_image($cache, 'png', $data['width'], $data['height']);
     }
     // something went wrong, we're missing the file
     if (!file_exists($cache)) {
         return false;
     }
     return $cache;
 }
开发者ID:superdav42,项目名称:dokuwiki-plugin-graphviz,代码行数:29,代码来源:syntax.php

示例9: mediaFN

    $FILE = mediaFN($MEDIA);
}
//check file existance
if (!@file_exists($FILE)) {
    header("HTTP/1.0 404 Not Found");
    //FIXME add some default broken image
    print 'Not Found';
    exit;
}
$ORIG = $FILE;
//handle image resizing/cropping
if (substr($MIME, 0, 5) == 'image' && $WIDTH) {
    if ($HEIGHT) {
        $FILE = media_crop_image($FILE, $EXT, $WIDTH, $HEIGHT);
    } else {
        $FILE = media_resize_image($FILE, $EXT, $WIDTH, $HEIGHT);
    }
}
// finally send the file to the client
$data = array('file' => $FILE, 'mime' => $MIME, 'download' => $DL, 'cache' => $CACHE, 'orig' => $ORIG, 'ext' => $EXT, 'width' => $WIDTH, 'height' => $HEIGHT);
$evt = new Doku_Event('MEDIA_SENDFILE', $data);
if ($evt->advise_before()) {
    sendFile($data['file'], $data['mime'], $data['download'], $data['cache']);
}
/* ------------------------------------------------------------------------ */
/**
 * Set headers and send the file to the client
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @author Ben Coburn <btcoburn@silicodon.net>
 */
开发者ID:lorea,项目名称:Hydra-dev,代码行数:31,代码来源:fetch.php

示例10: media_crop_image

/**
 * Crops the given image to the wanted ratio, then calls media_resize_image to scale it
 * to the wanted size
 *
 * Crops are centered horizontally but prefer the upper third of an vertical
 * image because most pics are more interesting in that area (rule of thirds)
 *
 * @author  Andreas Gohr <andi@splitbrain.org>
 */
function media_crop_image($file, $ext, $w, $h = 0)
{
    global $conf;
    if (!$h) {
        $h = $w;
    }
    $info = @getimagesize($file);
    //get original size
    if ($info == false) {
        return $file;
    }
    // that's no image - it's a spaceship!
    if ($conf['syslog']) {
        syslog(LOG_WARNING, '[media.php] media_crop_image: ' . $file . ', size: ' . $info[0] . 'x' . $info[1] . ', resize to:' . $w . 'x' . $h);
    }
    // calculate crop size
    $fr = $info[0] / $info[1];
    $tr = $w / $h;
    // check if the crop can be handled completely by resize,
    // i.e. the specified width & height match the aspect ratio of the source image
    // check rounding for either width or height to avoid cropping for portrait photos
    if ($w == round($h * $fr) || $h == round($w / $fr)) {
        if ($conf['syslog']) {
            syslog(LOG_WARNING, '[media.php] media_crop_image: use media_resize_image instead: ' . $file . ', width: ' . $w);
        }
        return media_resize_image($file, $ext, $w);
    }
    if ($conf['syslog']) {
        syslog(LOG_WARNING, '[media.php] media_crop_image: resize is not possible and we are doing crop now');
    }
    if ($conf['syslog']) {
        syslog(LOG_WARNING, '[media.php] media_crop_image: fr: ' . $fr . ' tr: ' . $tr . ' round w: ' . round($h * $fr)) . ' round h:' . round($w / $fr);
    }
    if ($tr >= 1) {
        if ($tr > $fr) {
            $cw = $info[0];
            $ch = (int) ($info[0] / $tr);
        } else {
            $cw = (int) ($info[1] * $tr);
            $ch = $info[1];
        }
    } else {
        if ($tr < $fr) {
            $cw = (int) ($info[1] * $tr);
            $ch = $info[1];
        } else {
            $cw = $info[0];
            $ch = (int) ($info[0] / $tr);
        }
    }
    // calculate crop offset
    $cx = (int) (($info[0] - $cw) / 2);
    $cy = (int) (($info[1] - $ch) / 3);
    //cache
    $local = getCacheName($file, '.media.' . $cw . 'x' . $ch . '.crop.' . $ext);
    $mtime = @filemtime($local);
    // 0 if not exists
    if ($mtime > @filemtime($file) || media_crop_imageIM($ext, $file, $info[0], $info[1], $local, $cw, $ch, $cx, $cy) || media_resize_imageGD($ext, $file, $cw, $ch, $local, $cw, $ch, $cx, $cy)) {
        if (!empty($conf['fperm'])) {
            @chmod($local, $conf['fperm']);
        }
        return media_resize_image($local, $ext, $w, $h);
    }
    //still here? cropping failed
    return media_resize_image($file, $ext, $w, $h);
}
开发者ID:s7mx1,项目名称:dokuwiki,代码行数:75,代码来源:media.php

示例11: _imgfile

 /**
  * Return path to the rendered image on our local system
  */
 function _imgfile($data)
 {
     $txt_data = $data;
     unset($txt_data['layer_n']);
     unset($txt_data['layer_cur']);
     if (isset($data['layer_n']) && isset($data['layer_cur']) && $data['layer_cur'] >= 0 && $data['layer_cur'] < $data['layer_n']) {
         $cache = $this->_cachename($data, sprintf("%d.png", $data['layer_cur']));
     } else {
         $cache = $this->_cachename($data, 'png');
     }
     // create the file if needed
     if (!file_exists($cache)) {
         $in = $this->_cachename($txt_data, 'txt');
         if ($this->getConf('path')) {
             $ok = $this->_run($data, $in, $cache);
         } else {
             $ok = $this->_remote($data, $in, $cache);
         }
         if (!$ok) {
             return false;
         }
         clearstatcache();
     }
     // resized version
     if ($data['width']) {
         $cache = media_resize_image($cache, 'png', $data['width'], $data['height']);
     }
     // something went wrong, we're missing the file
     if (!file_exists($cache)) {
         return false;
     }
     return $cache;
 }
开发者ID:nastasi,项目名称:dokuwiki-plugin-graphviz,代码行数:36,代码来源:syntax.php


注:本文中的media_resize_image函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。