本文整理汇总了PHP中WideImage::loadFromString方法的典型用法代码示例。如果您正苦于以下问题:PHP WideImage::loadFromString方法的具体用法?PHP WideImage::loadFromString怎么用?PHP WideImage::loadFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WideImage
的用法示例。
在下文中一共展示了WideImage::loadFromString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resize
function resize($src, $dest = null, $width, $height, $quality, $sx = null, $sy = null, $sw = null, $sh = null)
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
require_once dirname(__FILE__) . DS . 'wideimage' . DS . 'WideImage.php';
if (!isset($dest) || $dest == '') {
$dest = $src;
}
$ext = strtolower(JFile::getExt($src));
$src = @JFile::read($src);
if ($src) {
$image = @WideImage::loadFromString($src);
// cropped thumbnail
if (($sx || $sy) && $sw && $sh) {
$result = @$image->crop($sx, $sy, $sw, $sh)->resize($width, $height, 'fill');
} else {
$result = @$image->resize($width, $height);
}
switch ($ext) {
case 'jpg':
case 'jpeg':
$quality = intval($quality);
if ($this->get('ftp', 0)) {
@JFile::write($dest, $result->asString($ext, $quality));
} else {
@$result->saveToFile($dest, $quality);
}
break;
default:
if ($this->get('ftp', 0)) {
@JFile::write($dest, $result->asString($ext));
} else {
@$result->saveToFile($dest);
}
break;
}
unset($image);
unset($result);
}
if (file_exists($dest)) {
@JPath::setPermissions($dest);
return $dest;
}
return false;
}
示例2: copyNoAlpha
/**
* (non-PHPdoc)
* @see WideImage_Image#copyNoAlpha()
*/
function copyNoAlpha()
{
return WideImage::loadFromString($this->asString('png'));
}
示例3: testInvalidImageStringData
/**
* @expectedException WideImage_InvalidImageSourceException
*/
function testInvalidImageStringData()
{
WideImage::loadFromString('asdf');
}
示例4: __wakeup
/**
* Restores an image from serialization. Called automatically upon unserialize().
*/
function __wakeup()
{
$temp_image = WideImage::loadFromString($this->sdata);
$temp_image->releaseHandle();
$this->handle = $temp_image->handle;
$temp_image = null;
$this->sdata = null;
}
示例5: copyNoAlpha
/**
* (non-PHPdoc)
* @see WideImage_Image#copyNoAlpha()
*/
function copyNoAlpha()
{
$prev = $this->saveAlpha(false);
$result = WideImage::loadFromString($this->asString('png'));
$this->saveAlpha($prev);
//$result->releaseHandle();
return $result;
}
示例6: filter_input
$args[] = filter_input(INPUT_GET, 'arg1', FILTER_SANITIZE_STRING);
}
if (isset($_GET['arg2'])) {
$args[] = filter_input(INPUT_GET, 'arg2', FILTER_SANITIZE_STRING);
}
if (isset($_GET['arg3'])) {
$args[] = filter_input(INPUT_GET, 'arg3', FILTER_SANITIZE_STRING);
}
$image_handler = icms::handler('icms_image');
$imgcat_handler = icms::handler('icms_image_category');
$image =& $image_handler->getObjects(new icms_db_criteria_Item('image_name', $file), FALSE, TRUE);
$imagecategory =& $imgcat_handler->get($image[0]->getVar('imgcat_id'));
$categ_path = $imgcat_handler->getCategFolder($imagecategory);
$categ_url = $imgcat_handler->getCategFolder($imagecategory, 1, 'url');
if ($imagecategory->getVar('imgcat_storetype') == 'db') {
$img = WideImage::loadFromString($image[0]->getVar('image_body'));
} else {
$path = substr($categ_path, -1) != '/' ? $categ_path . '/' : $categ_path;
$img = WideImage::load($path . $file);
}
$width = $img->getWidth();
$height = $img->getHeight();
header('Content-type: image/png');
if (NULL !== $filter) {
if ($filter == 'IMG_FILTER_SEPIA') {
if ($resize && ($width > 400 || $height > 300)) {
echo $img->resize(400, 300)->applyFilter(IMG_FILTER_GRAYSCALE)->applyFilter(IMG_FILTER_COLORIZE, 90, 60, 30)->asString('png');
} else {
echo $img->applyFilter(IMG_FILTER_GRAYSCALE)->applyFilter(IMG_FILTER_COLORIZE, 90, 60, 30)->asString('png');
}
} else {
示例7: file_get_contents
//Set JPG image header
//If they don't have a profile picture
if (trim($profile_pic) == "" || count($personInfo) == 0) {
//Use the default one
$profile_pic = file_get_contents($_SERVER["DOC_ROOT"] . "/img/user_icon_200.png");
}
//If a filter is specified...
if (isset($_GET["filter"])) {
//Apply it accordingly
switch (strtolower(trim($_GET["filter"]))) {
case "blur":
//Blur the image
$feat_data_binary_blur = WideImage::loadFromString($profile_pic)->applyFilter(IMG_FILTER_GAUSSIAN_BLUR);
for ($i = 0; $i < 50; $i++) {
$get_cur_blur = $feat_data_binary_blur->asString('jpg');
$feat_data_binary_blur = WideImage::loadFromString($get_cur_blur)->applyFilter(IMG_FILTER_GAUSSIAN_BLUR);
}
$profile_pic = $feat_data_binary_blur->asString('jpg');
break;
}
}
//If a size is specified...
if (isset($_GET["size"])) {
//Resize it accordingly
switch (strtolower(trim($_GET["size"]))) {
case "small":
//(60x60)
$profile_pic = WideImage::load($profile_pic)->resize(50)->asString('jpg');
break;
case "huge":
//(60x60)
示例8: header
* Last Updated: 6/5/2014
* Signature: Tyler Nickerson
* Copyright 2014 eDart
*
* [Do not remove this header. One MUST be included at the start of every page/script]
*
*/
header("Content-type: image/jpg");
include_once $_SERVER["DOC_ROOT"] . "/scripts/php/core.php";
//Import core functionality
//Get current user's info
$thisUser = new User(array("action" => "get", "id" => $_SESSION["userid"]));
$userInfo = $thisUser->run(true);
//Get the current user's profile picture
$contents = $userInfo[0]["profile_pic"];
//If it isn't set...
if (trim($contents) == "") {
//...use the default image
$contents = file_get_contents($_SERVER["DOC_ROOT"] . "/img/user_icon_200.png");
}
//If a size is specified...
if (isset($_GET["size"])) {
switch (strtolower($_GET["size"])) {
//Change the image accordingly
case "small":
$contents = WideImage::loadFromString($contents)->resize(50)->asString('jpg');
break;
}
}
echo $contents;
//Print the image
示例9: die
$imgcat_handler = icms::handler('icms_image_category');
$imagecategory =& $imgcat_handler->get($original_image->getVar('imgcat_id'));
if (!is_object($imagecategory)) {
die(_ERROR);
}
$categ_path = $imgcat_handler->getCategFolder($imagecategory);
$categ_path = substr($categ_path, -1) != '/' ? $categ_path . '/' : $categ_path;
$categ_url = $imgcat_handler->getCategFolder($imagecategory, 1, 'url');
$categ_url = substr($categ_url, -1) != '/' ? $categ_url . '/' : $categ_url;
#Creating the temporary image. This temp image that will be edited and at the end will be converted to the final image.
$temp_img_name = 'temp_' . $uniq . '_' . $original_image->getVar('image_name');
$orig_img_name = 'orig_' . $uniq . '_' . $original_image->getVar('image_name');
if (!file_exists(ICMS_IMANAGER_FOLDER_PATH . '/temp/' . $temp_img_name)) {
if ($imagecategory->getVar('imgcat_storetype') == 'db') {
$temp_img = WideImage::loadFromString($original_image->getVar('image_body'));
$orig_img = WideImage::loadFromString($original_image->getVar('image_body'));
} else {
$temp_img = WideImage::load($categ_path . $original_image->getVar('image_name'));
$orig_img = WideImage::load($categ_path . $original_image->getVar('image_name'));
}
$temp_img->saveToFile(ICMS_IMANAGER_FOLDER_PATH . '/temp/' . $temp_img_name);
$orig_img->saveToFile(ICMS_IMANAGER_FOLDER_PATH . '/temp/' . $orig_img_name);
} else {
$temp_img = WideImage::load(ICMS_IMANAGER_FOLDER_PATH . '/temp/' . $temp_img_name);
$orig_img = WideImage::load(ICMS_IMANAGER_FOLDER_PATH . '/temp/' . $orig_img_name);
}
$img = array();
$img['name'] = $temp_img_name;
$img['originalname'] = $original_image->getVar('image_name');
$img['id'] = $original_image->getVar('image_id');
$img['title'] = $original_image->getVar('image_nicename');