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


PHP OC_Image::centerCrop方法代码示例

本文整理汇总了PHP中OC_Image::centerCrop方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Image::centerCrop方法的具体用法?PHP OC_Image::centerCrop怎么用?PHP OC_Image::centerCrop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC_Image的用法示例。


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

示例1: handleGetAlbumThumbnail

function handleGetAlbumThumbnail($token, $albumname)
{
    $owner = OC_Gallery_Sharing::getTokenOwner($token);
    $file = OCP\Config::getSystemValue("datadirectory") . '/' . $owner . '/gallery/' . $albumname . '.png';
    $image = new OC_Image($file);
    if ($image->valid()) {
        $image->centerCrop();
        $image->resize(200);
        $image->fixOrientation();
        OCP\Response::enableCaching(3600 * 24);
        // 24 hour
        $image->show();
    }
}
开发者ID:noci2012,项目名称:owncloud,代码行数:14,代码来源:sharing.php

示例2: handleGetAlbumThumbnail

function handleGetAlbumThumbnail($token, $albumname)
{
    $owner = OC_Gallery_Sharing::getTokenOwner($token);
    $view = OCP\Files::getStorage('gallery');
    $file = $view->fopen($albumname . '.png', 'r');
    $image = new OC_Image($file);
    if ($image->valid()) {
        $image->centerCrop();
        $image->resize(200);
        $image->fixOrientation();
        OCP\Response::enableCaching(3600 * 24);
        // 24 hour
        $image->show();
    }
}
开发者ID:blablubli,项目名称:owncloudapps,代码行数:15,代码来源:sharing.php

示例3: testCenterCrop

 public function testCenterCrop()
 {
     $img = new \OC_Image(OC::$SERVERROOT . '/tests/data/testimage.png');
     $img->centerCrop();
     $this->assertEquals(128, $img->width());
     $this->assertEquals(128, $img->height());
     $img = new \OC_Image(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
     $img->centerCrop();
     $this->assertEquals(1050, $img->width());
     $this->assertEquals(1050, $img->height());
     $img = new \OC_Image(base64_encode(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.gif')));
     $img->centerCrop(512);
     $this->assertEquals(512, $img->width());
     $this->assertEquals(512, $img->height());
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:15,代码来源:image.php

示例4: getThumbnail

 public static function getThumbnail($image_name, $owner = null)
 {
     if (!$owner) {
         $owner = OCP\USER::getUser();
     }
     $save_dir = OCP\Config::getSystemValue("datadirectory") . '/' . $owner . '/gallery/';
     $save_dir .= dirname($image_name) . '/';
     $image_path = $image_name;
     $thumb_file = $save_dir . basename($image_name);
     if (!is_dir($save_dir)) {
         mkdir($save_dir, 0777, true);
     }
     if (file_exists($thumb_file)) {
         $image = new OC_Image($thumb_file);
     } else {
         $image_path = OC_Filesystem::getLocalFile($image_path);
         if (!file_exists($image_path)) {
             return null;
         }
         $image = new OC_Image($image_path);
         if ($image->valid()) {
             $image->centerCrop(200);
             $image->fixOrientation();
             $image->save($thumb_file);
         }
     }
     if ($image->valid()) {
         return $image;
     } else {
         $image->destroy();
     }
     return null;
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:33,代码来源:photo.php

示例5: getThumbnail

 public static function getThumbnail($image_name, $owner = null)
 {
     if (!$owner) {
         $owner = OCP\USER::getUser();
     }
     $view = OCP\Files::getStorage('gallery');
     $save_dir = dirname($image_name);
     if (!$view->is_dir($save_dir)) {
         $view->mkdir($save_dir);
     }
     $view->chroot($view->getRoot() . '/' . $save_dir);
     $thumb_file = basename($image_name);
     if ($view->file_exists($thumb_file)) {
         $image = new OC_Image($view->fopen($thumb_file, 'r'));
     } else {
         $image_path = OC_Filesystem::getLocalFile($image_name);
         if (!file_exists($image_path)) {
             return null;
         }
         $image = new OC_Image($image_path);
         if ($image->valid()) {
             $image->centerCrop(200);
             $image->fixOrientation();
             $image->save($view->getLocalFile($thumb_file));
         }
     }
     if ($image->valid()) {
         return $image;
     } else {
         $image->destroy();
     }
     return null;
 }
开发者ID:noldmess,项目名称:apps,代码行数:33,代码来源:photo.php

示例6: getStandardImage

// invalid vcard
if (is_null($contact)) {
    OCP\Util::writeLog('contacts', 'thumbnail.php. The VCard for ID ' . $id . ' is not RFC compatible', OCP\Util::ERROR);
    getStandardImage();
    exit;
}
OCP\Response::enableCaching($caching);
OC_Contacts_App::setLastModifiedHeader($contact);
$thumbnail_size = 23;
// Find the photo from VCard.
$image = new OC_Image();
$photo = $contact->getAsString('PHOTO');
if ($photo) {
    OCP\Response::setETagHeader(md5($photo));
    if ($image->loadFromBase64($photo)) {
        if ($image->centerCrop()) {
            if ($image->resize($thumbnail_size)) {
                if ($image->show()) {
                    // done
                    exit;
                } else {
                    OCP\Util::writeLog('contacts', 'thumbnail.php. Couldn\'t display thumbnail for ID ' . $id, OCP\Util::ERROR);
                }
            } else {
                OCP\Util::writeLog('contacts', 'thumbnail.php. Couldn\'t resize thumbnail for ID ' . $id, OCP\Util::ERROR);
            }
        } else {
            OCP\Util::writeLog('contacts', 'thumbnail.php. Couldn\'t crop thumbnail for ID ' . $id, OCP\Util::ERROR);
        }
    } else {
        OCP\Util::writeLog('contacts', 'thumbnail.php. Couldn\'t load image string for ID ' . $id, OCP\Util::ERROR);
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:31,代码来源:thumbnail.php

示例7: cacheThumbnail

 public static function cacheThumbnail($id, \OC_Image $image = null)
 {
     if (\OC_Cache::hasKey(self::THUMBNAIL_PREFIX . $id)) {
         return \OC_Cache::get(self::THUMBNAIL_PREFIX . $id);
     }
     if (is_null($image)) {
         $vcard = self::getContactVCard($id);
         // invalid vcard
         if (is_null($vcard)) {
             \OCP\Util::writeLog('contacts', __METHOD__ . ' The VCard for ID ' . $id . ' is not RFC compatible', \OCP\Util::ERROR);
             return false;
         }
         $image = new \OC_Image();
         if (!isset($vcard->PHOTO)) {
             return false;
         }
         if (!$image->loadFromBase64((string) $vcard->PHOTO)) {
             return false;
         }
     }
     if (!$image->centerCrop()) {
         \OCP\Util::writeLog('contacts', 'thumbnail.php. Couldn\'t crop thumbnail for ID ' . $id, \OCP\Util::ERROR);
         return false;
     }
     if (!$image->resize(self::THUMBNAIL_SIZE)) {
         \OCP\Util::writeLog('contacts', 'thumbnail.php. Couldn\'t resize thumbnail for ID ' . $id, \OCP\Util::ERROR);
         return false;
     }
     // Cache for around a month
     \OC_Cache::set(self::THUMBNAIL_PREFIX . $id, $image->data(), 3000000);
     \OCP\Util::writeLog('contacts', 'Caching ' . $id, \OCP\Util::DEBUG);
     return \OC_Cache::get(self::THUMBNAIL_PREFIX . $id);
 }
开发者ID:nanowish,项目名称:apps,代码行数:33,代码来源:app.php

示例8: rtrim

<?php

// Get the data
$imageData = $_POST['canv_data'];
$title = rtrim($_POST['title'], 'pdf');
$location = urldecode(dirname($_POST['location']));
if ($location != '/') {
    $location = $location . '/';
}
$filteredData = substr($imageData, strpos($imageData, ",") + 1);
$owner = OCP\USER::getUser();
$save_dir = OCP\Config::getSystemValue("datadirectory") . '/' . $owner . '/reader';
$save_dir .= $location;
$thumb_file = $save_dir . $title;
if (!is_dir($save_dir)) {
    mkdir($save_dir, 0777, true);
}
$image = new OC_Image($filteredData);
if ($image->valid()) {
    $image->centerCrop(100);
    $image->fixOrientation();
    $image->save($thumb_file . 'png');
}
开发者ID:DOM-Digital-Online-Media,项目名称:apps,代码行数:23,代码来源:canvas_saver.php


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