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


PHP OC_Image::height方法代码示例

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


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

示例1: set

 /**
  * sets the users avatar
  * @param \OC_Image|resource|string $data OC_Image, imagedata or path to set a new avatar
  * @throws Exception if the provided file is not a jpg or png image
  * @throws Exception if the provided image is not valid
  * @throws \OC\NotSquareException if the image is not square
  * @return void
  */
 public function set($data)
 {
     if ($data instanceof OC_Image) {
         $img = $data;
         $data = $img->data();
     } else {
         $img = new OC_Image($data);
     }
     $type = substr($img->mimeType(), -3);
     if ($type === 'peg') {
         $type = 'jpg';
     }
     if ($type !== 'jpg' && $type !== 'png') {
         $l = \OC_L10N::get('lib');
         throw new \Exception($l->t("Unknown filetype"));
     }
     if (!$img->valid()) {
         $l = \OC_L10N::get('lib');
         throw new \Exception($l->t("Invalid image"));
     }
     if (!($img->height() === $img->width())) {
         throw new \OC\NotSquareException();
     }
     $this->view->unlink('avatar.jpg');
     $this->view->unlink('avatar.png');
     $this->view->file_put_contents('avatar.' . $type, $data);
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:35,代码来源:avatar.php

示例2: getThumbnail

 public function getThumbnail($path)
 {
     $gallery_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/gallery';
     if (file_exists($gallery_path . $path)) {
         return new \OC_Image($gallery_path . $path);
     }
     if (!\OC_Filesystem::file_exists($path)) {
         \OC_Log::write(self::TAG, 'File ' . $path . ' don\'t exists', \OC_Log::WARN);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromFile(\OC_Filesystem::getLocalFile($path));
     if (!$image->valid()) {
         return false;
     }
     $image->fixOrientation();
     $ret = $image->preciseResize(floor(150 * $image->width() / $image->height()), 150);
     if (!$ret) {
         \OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR);
         unset($image);
         return false;
     }
     $image->save($gallery_path . '/' . $path);
     return $image;
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:25,代码来源:managers.php

示例3: testFitIn

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

示例4: bailOut

}
if (!isset($_GET['path'])) {
    bailOut(OC_Contacts_App::$l10n->t('No photo path was submitted.'));
}
$localpath = OC_Filesystem::getLocalFile($_GET['path']);
$tmpfname = tempnam(get_temp_dir(), "occOrig");
if (!file_exists($localpath)) {
    bailOut(OC_Contacts_App::$l10n->t('File doesn\'t exist:') . $localpath);
}
file_put_contents($tmpfname, file_get_contents($localpath));
$image = new OC_Image();
if (!$image) {
    bailOut(OC_Contacts_App::$l10n->t('Error loading image.'));
}
if (!$image->loadFromFile($tmpfname)) {
    bailOut(OC_Contacts_App::$l10n->t('Error loading image.'));
}
if ($image->width() > 400 || $image->height() > 400) {
    $image->resize(400);
    // Prettier resizing than with browser and saves bandwidth.
}
if (!$image->fixOrientation()) {
    // No fatal error so we don't bail out.
    debug('Couldn\'t save correct image orientation: ' . $tmpfname);
}
if ($image->save($tmpfname)) {
    OCP\JSON::success(array('data' => array('id' => $_GET['id'], 'tmp' => $tmpfname)));
    exit;
} else {
    bailOut('Couldn\'t save temporary image: ' . $tmpfname);
}
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:31,代码来源:oc_photo.php

示例5: testScaleDownWhenBigger

 /**
  * @dataProvider largeSampleProvider
  *
  * @param string $filename
  * @param int[] $asked
  * @param int[] $expected
  */
 public function testScaleDownWhenBigger($filename, $asked, $expected)
 {
     $img = new \OC_Image(OC::$SERVERROOT . '/tests/data/' . $filename);
     //$this->assertTrue($img->scaleDownToFit($asked[0], $asked[1]));
     $img->scaleDownToFit($asked[0], $asked[1]);
     $this->assertEquals($expected[0], $img->width());
     $this->assertEquals($expected[1], $img->height());
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:15,代码来源:ImageTest.php

示例6: getStandardImage

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);
        }
    }
}
if (!$image->valid()) {
    // Not found :-(
    getStandardImage();
    //$image->loadFromFile('img/person_large.png');
}
header('Content-Type: ' . $image->mimeType());
$image->show();
//echo OC_Contacts_App::$l10n->t('This card does not contain a photo.');
开发者ID:noci2012,项目名称:owncloud,代码行数:31,代码来源:photo.php

示例7: isset

$h = isset($_POST['h']) && $_POST['h'] ? $_POST['h'] : -1;
$tmpkey = isset($_POST['tmpkey']) ? $_POST['tmpkey'] : '';
$id = isset($_POST['id']) ? $_POST['id'] : '';
if ($tmpkey == '') {
    bailOut('Missing key to temporary file.');
}
if ($id == '') {
    bailOut('Missing contact id.');
}
OCP\Util::writeLog('contacts', 'savecrop.php: key: ' . $tmpkey, OCP\Util::DEBUG);
$data = OC_Cache::get($tmpkey);
if ($data) {
    $image = new OC_Image();
    if ($image->loadFromdata($data)) {
        $w = $w != -1 ? $w : $image->width();
        $h = $h != -1 ? $h : $image->height();
        OCP\Util::writeLog('contacts', 'savecrop.php, x: ' . $x1 . ' y: ' . $y1 . ' w: ' . $w . ' h: ' . $h, OCP\Util::DEBUG);
        if ($image->crop($x1, $y1, $w, $h)) {
            if ($image->width() <= 200 && $image->height() <= 200 || $image->resize(200)) {
                $vcard = OCA\Contacts\App::getContactVCard($id);
                if (!$vcard) {
                    OC_Cache::remove($tmpkey);
                    bailOut(OCA\Contacts\App::$l10n->t('Error getting contact object.'));
                }
                if ($vcard->__isset('PHOTO')) {
                    OCP\Util::writeLog('contacts', 'savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
                    $property = $vcard->__get('PHOTO');
                    if (!$property) {
                        OC_Cache::remove($tmpkey);
                        bailOut(OCA\Contacts\App::$l10n->t('Error getting PHOTO property.'));
                    }
开发者ID:netcon-source,项目名称:apps,代码行数:31,代码来源:savecrop.php

示例8: isset

$h = isset($_POST['h']) && $_POST['h'] ? $_POST['h'] : -1;
$tmpkey = isset($_POST['tmpkey']) ? $_POST['tmpkey'] : '';
$id = isset($_POST['id']) ? $_POST['id'] : '';
if ($tmpkey == '') {
    bailOut('Missing key to temporary file.');
}
if ($id == '') {
    bailOut('Missing contact id.');
}
OCP\Util::writeLog('contacts', 'savecrop.php: key: ' . $tmpkey, OCP\Util::DEBUG);
$data = OC_Cache::get($tmpkey);
if ($data) {
    $image = new OC_Image();
    if ($image->loadFromdata($data)) {
        $w = $w != -1 ? $w : $image->width();
        $h = $h != -1 ? $h : $image->height();
        OCP\Util::writeLog('contacts', 'savecrop.php, x: ' . $x1 . ' y: ' . $y1 . ' w: ' . $w . ' h: ' . $h, OCP\Util::DEBUG);
        if ($image->crop($x1, $y1, $w, $h)) {
            if ($image->width() <= 200 && $image->height() <= 200 || $image->resize(200)) {
                $vcard = OC_Contacts_App::getContactVCard($id);
                if (!$vcard) {
                    OC_Cache::remove($tmpkey);
                    bailOut(OC_Contacts_App::$l10n->t('Error getting contact object.'));
                }
                if ($vcard->__isset('PHOTO')) {
                    OCP\Util::writeLog('contacts', 'savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
                    $property = $vcard->__get('PHOTO');
                    if (!$property) {
                        OC_Cache::remove($tmpkey);
                        bailOut(OC_Contacts_App::$l10n->t('Error getting PHOTO property.'));
                    }
开发者ID:blablubli,项目名称:owncloudapps,代码行数:31,代码来源:savecrop.php

示例9: isset

$w = isset($_POST['w']) && $_POST['w'] ? $_POST['w'] : -1;
$h = isset($_POST['h']) && $_POST['h'] ? $_POST['h'] : -1;
$tmp_path = isset($_POST['tmp_path']) ? $_POST['tmp_path'] : '';
$id = isset($_POST['id']) ? $_POST['id'] : '';
if ($tmp_path == '') {
    bailOut('Missing path to temporary file.');
}
if ($id == '') {
    bailOut('Missing contact id.');
}
OCP\Util::writeLog('contacts', 'savecrop.php: files: ' . $tmp_path . '  exists: ' . file_exists($tmp_path), OCP\Util::DEBUG);
if (file_exists($tmp_path)) {
    $image = new OC_Image();
    if ($image->loadFromFile($tmp_path)) {
        $w = $w != -1 ? $w : $image->width();
        $h = $h != -1 ? $h : $image->height();
        OCP\Util::writeLog('contacts', 'savecrop.php, x: ' . $x1 . ' y: ' . $y1 . ' w: ' . $w . ' h: ' . $h, OCP\Util::DEBUG);
        if ($image->crop($x1, $y1, $w, $h)) {
            if ($image->width() <= 200 && $image->height() <= 200 || $image->resize(200)) {
                $tmpfname = tempnam(get_temp_dir(), "occCropped");
                // create a new file because of caching issues.
                if ($image->save($tmpfname)) {
                    unlink($tmp_path);
                    $card = OC_Contacts_App::getContactVCard($id);
                    if (!$card) {
                        unlink($tmpfname);
                        bailOut('Error getting contact object.');
                    }
                    if ($card->__isset('PHOTO')) {
                        OCP\Util::writeLog('contacts', 'savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
                        $property = $card->__get('PHOTO');
开发者ID:noci2012,项目名称:owncloud,代码行数:31,代码来源:savecrop.php

示例10: getThumbnail

 public function getThumbnail($path)
 {
     $gallery_storage = \OCP\Files::getStorage('gallery');
     if ($gallery_storage->file_exists($path)) {
         return new \OC_Image($gallery_storage->getLocalFile($path));
     }
     if (!\OC_Filesystem::file_exists($path)) {
         \OC_Log::write(self::TAG, 'File ' . $path . ' don\'t exists', \OC_Log::WARN);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromFile(\OC_Filesystem::getLocalFile($path));
     if (!$image->valid()) {
         return false;
     }
     $image->fixOrientation();
     $ret = $image->preciseResize(floor(self::THUMBNAIL_HEIGHT * $image->width() / $image->height()), self::THUMBNAIL_HEIGHT);
     if (!$ret) {
         \OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR);
         unset($image);
         return false;
     }
     $l = $gallery_storage->getLocalFile($path);
     $image->save($l);
     return $image;
 }
开发者ID:blablubli,项目名称:owncloudapps,代码行数:26,代码来源:managers.php


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