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


PHP OC_Image::save方法代码示例

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


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

示例1: testConvert

 /**
  * @dataProvider convertDataProvider
  */
 public function testConvert($mimeType)
 {
     $img = new \OC_Image(OC::$SERVERROOT . '/tests/data/testimage.png');
     $tempFile = tempnam(sys_get_temp_dir(), 'img-test');
     $img->save($tempFile, $mimeType);
     $actualMimeType = \OC_Image::getMimeTypeForFile($tempFile);
     $this->assertEquals($mimeType, $actualMimeType);
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:11,代码来源:image.php

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

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

示例4: getViewImage

 public static function getViewImage($image_name, $owner = null)
 {
     if (!$owner) {
         $owner = OCP\USER::getUser();
     }
     $view_file = OC_Filesystem::getLocalFile($image_name);
     if (!is_dir($save_dir)) {
         mkdir($save_dir, 0777, true);
     }
     if (file_exists($view_file)) {
         $image = new OC_Image($view_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->resize(1200);
             $image->fixOrientation();
             $image->save($view_file);
         }
     }
     if ($image->valid()) {
         return $image;
     } else {
         $image->destroy();
     }
     return null;
 }
开发者ID:noldmess,项目名称:apps,代码行数:30,代码来源:photo.php

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