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


PHP OC_Image::loadFromBase64方法代码示例

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


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

示例1: getStandardImage

    OCP\Util::writeLog('contacts', 'photo.php. GD module not installed', OCP\Util::DEBUG);
    getStandardImage();
}
$contact = OC_Contacts_App::getContactVCard($id);
$image = new OC_Image();
if (!$image) {
    getStandardImage();
}
// invalid vcard
if (is_null($contact)) {
    OCP\Util::writeLog('contacts', 'photo.php. The VCard for ID ' . $id . ' is not RFC compatible', OCP\Util::ERROR);
} else {
    OCP\Response::enableCaching($caching);
    OC_Contacts_App::setLastModifiedHeader($contact);
    // Photo :-)
    if ($image->loadFromBase64($contact->getAsString('PHOTO'))) {
        // OK
        OCP\Response::setETagHeader(md5($contact->getAsString('PHOTO')));
    } else {
        // Logo :-/
        if ($image->loadFromBase64($contact->getAsString('LOGO'))) {
            // OK
            OCP\Response::setETagHeader(md5($contact->getAsString('LOGO')));
        }
    }
    if ($image->valid()) {
        $max_size = 200;
        if ($image->width() > $max_size || $image->height() > $max_size) {
            $image->resize($max_size);
        }
    }
开发者ID:noci2012,项目名称:owncloud,代码行数:31,代码来源:photo.php

示例2: bailOut

 */
// Firefox and Konqueror tries to download application/json for me.  --Arthur
OCP\JSON::setContentTypeHeader('text/plain');
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
require_once 'loghandler.php';
if (!isset($_GET['id'])) {
    bailOut(OCA\Contacts\App::$l10n->t('No contact ID was submitted.'));
}
$contact = OCA\Contacts\App::getContactVCard($_GET['id']);
// invalid vcard
if (is_null($contact)) {
    bailOut(OCA\Contacts\App::$l10n->t('Error reading contact photo.'));
} else {
    $image = new OC_Image();
    if (!isset($contact->PHOTO) || !$image->loadFromBase64((string) $contact->PHOTO)) {
        if (isset($contact->LOGO)) {
            $image->loadFromBase64((string) $contact->LOGO);
        }
    }
    if ($image->valid()) {
        $tmpkey = 'contact-photo-' . $contact->UID;
        if (OC_Cache::set($tmpkey, $image->data(), 600)) {
            OCP\JSON::success(array('data' => array('id' => $_GET['id'], 'tmp' => $tmpkey)));
            exit;
        } else {
            bailOut(OCA\Contacts\App::$l10n->t('Error saving temporary file.'));
        }
    } else {
        bailOut(OCA\Contacts\App::$l10n->t('The loading photo is not valid.'));
    }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:currentphoto.php

示例3: 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

示例4: getStandardImage

$contact = OC_Contacts_App::getContactVCard($id);
// 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 {
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:31,代码来源:thumbnail.php

示例5: getStandardImage

}
if (!extension_loaded('gd') || !function_exists('gd_info')) {
    OCP\Util::writeLog('contacts', 'photo.php. GD module not installed', OCP\Util::DEBUG);
    getStandardImage();
}
$contact = OCA\Contacts\App::getContactVCard($id);
$image = new OC_Image();
if (!$image || !$contact) {
    getStandardImage();
}
// invalid vcard
if (is_null($contact)) {
    OCP\Util::writeLog('contacts', 'photo.php. The VCard for ID ' . $id . ' is not RFC compatible', OCP\Util::ERROR);
} else {
    // Photo :-)
    if (isset($contact->PHOTO) && $image->loadFromBase64((string) $contact->PHOTO)) {
        // OK
        $etag = md5($contact->PHOTO);
    } else {
        // Logo :-/
        if (isset($contact->LOGO) && $image->loadFromBase64((string) $contact->LOGO)) {
            // OK
            $etag = md5($contact->LOGO);
        }
    }
    if ($image->valid()) {
        $modified = OCA\Contacts\App::lastModified($contact);
        // Force refresh if modified within the last minute.
        if (!is_null($modified)) {
            $caching = time() - $modified->format('U') > 60 ? null : 0;
        }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:photo.php


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