本文整理汇总了PHP中get_resized_image_from_existing_file函数的典型用法代码示例。如果您正苦于以下问题:PHP get_resized_image_from_existing_file函数的具体用法?PHP get_resized_image_from_existing_file怎么用?PHP get_resized_image_from_existing_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_resized_image_from_existing_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: zhsocial_apply_icon
function zhsocial_apply_icon($zh_user, $icon_url)
{
// if($zh_user->icontime)
// return;
$icon_sizes = elgg_get_config('icon_sizes');
$prefix = "profile/{$zh_user->guid}";
$filehandler = new ElggFile();
$filehandler->owner_guid = $zh_user->guid;
$filehandler->setFilename($prefix . ".jpg");
$filehandler->open("write");
$filehandler->write(file_get_contents($icon_url));
$filehandler->close();
$filename = $filehandler->getFilenameOnFilestore();
$sizes = array('topbar', 'tiny', 'small', 'medium', 'large', 'master');
$thumbs = array();
foreach ($sizes as $size) {
$thumbs[$size] = get_resized_image_from_existing_file($filename, $icon_sizes[$size]['w'], $icon_sizes[$size]['h'], $icon_sizes[$size]['square']);
}
if ($thumbs['tiny']) {
// just checking if resize successful
$thumb = new ElggFile();
$thumb->owner_guid = $zh_user->guid;
$thumb->setMimeType('image/jpeg');
foreach ($sizes as $size) {
$thumb->setFilename("{$prefix}{$size}.jpg");
$thumb->open("write");
$thumb->write($thumbs[$size]);
$thumb->close();
}
$zh_user->icontime = time();
}
}
示例2: form_generate_thumbnail
function form_generate_thumbnail($file, $fieldname)
{
// Generate thumbnail (if image)
$prefix = "file/";
$filestorename = strtolower(time() . $_FILES[$fieldname]['name']);
if (substr_count($file->getMimeType(), 'image/')) {
$thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 60, 60, true);
$thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 153, 153, true);
$thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 600, 600, false);
if ($thumbnail) {
$thumb = new ElggFile();
$thumb->setMimeType($_FILES[$fieldname]['type']);
$thumb->setFilename($prefix . "thumb" . $filestorename);
$thumb->open("write");
$thumb->write($thumbnail);
$thumb->close();
$file->thumbnail = $prefix . "thumb" . $filestorename;
$thumb->setFilename($prefix . "smallthumb" . $filestorename);
$thumb->open("write");
$thumb->write($thumbsmall);
$thumb->close();
$file->smallthumb = $prefix . "smallthumb" . $filestorename;
$thumb->setFilename($prefix . "largethumb" . $filestorename);
$thumb->open("write");
$thumb->write($thumblarge);
$thumb->close();
$file->largethumb = $prefix . "largethumb" . $filestorename;
}
}
}
示例3: pleiofile_generate_file_thumbs
function pleiofile_generate_file_thumbs(ElggObject $file)
{
if ($file->simpletype != "image") {
return null;
}
$file->icontime = time();
$sizes = array(60 => "thumb", 153 => "tinythumb", 153 => "smallthumb", 600 => "largethumb");
$filename = str_replace("file/", "", $file->getFilename());
foreach ($sizes as $size => $description) {
if ($size < 600) {
$upscale = true;
} else {
$upscale = false;
}
$thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), $size, $size, $upscale);
if ($thumbnail) {
$path = "file/" . $description . "_" . $filename;
$thumb = new ElggFile();
$thumb->setMimeType($_FILES['upload']['type']);
$thumb->setFilename($path);
$thumb->open("write");
$thumb->write($thumbnail);
$thumb->close();
if ($description == "thumb") {
$file->thumbnail = $path;
} else {
$file->{$description} = $path;
}
unset($thumbnail);
}
}
}
示例4: get_resized_image_from_uploaded_file
/**
* Gets the jpeg contents of the resized version of an uploaded image
* (Returns false if the uploaded file was not an image)
*
* @param string $input_name The name of the file input field on the submission form
* @param int $maxwidth The maximum width of the resized image
* @param int $maxheight The maximum height of the resized image
* @param bool $square If set to true, will take the smallest
* of maxwidth and maxheight and use it to set the
* dimensions on all size; the image will be cropped.
* @param bool $upscale Resize images smaller than $maxwidth x $maxheight?
*
* @return false|mixed The contents of the resized image, or false on failure
*/
function get_resized_image_from_uploaded_file($input_name, $maxwidth, $maxheight, $square = false, $upscale = false)
{
// If our file exists ...
if (isset($_FILES[$input_name]) && $_FILES[$input_name]['error'] == 0) {
return get_resized_image_from_existing_file($_FILES[$input_name]['tmp_name'], $maxwidth, $maxheight, $square, 0, 0, 0, 0, $upscale);
}
return false;
}
示例5: get_resized_image_from_uploaded_file
/**
* Gets the jpeg contents of the resized version of an uploaded image
* (Returns false if the uploaded file was not an image)
*
* @param string $input_name The name of the file input field on the submission form
* @param int $maxwidth The maximum width of the resized image
* @param int $maxheight The maximum height of the resized image
* @param bool $square If set to true, will take the smallest
* of maxwidth and maxheight and use it to set the
* dimensions on all size; the image will be cropped.
* @param bool $upscale Resize images smaller than $maxwidth x $maxheight?
*
* @return false|mixed The contents of the resized image, or false on failure
*/
function get_resized_image_from_uploaded_file($input_name, $maxwidth, $maxheight, $square = false, $upscale = false)
{
$files = _elgg_services()->request->files;
if (!$files->has($input_name)) {
return false;
}
$file = $files->get($input_name);
if (elgg_extract('error', $file) !== 0) {
return false;
}
return get_resized_image_from_existing_file(elgg_extract('tmp_name', $file), $maxwidth, $maxheight, $square, 0, 0, 0, 0, $upscale);
}
示例6: CreateLTIGroup
function CreateLTIGroup($user, $name, $context_id, $consumer_key)
{
$group_guid = 0;
$group = new ElggGroup($group_guid);
// Set the group properties that we can!
$group->name = $name;
$group->context_id = $context_id;
// This is a unique identifier from the consumer for this context
$group->consumer_key = $consumer_key;
// Which consumer is creating this group
$group->membership = ACCESS_PRIVATE;
$group->access_id = ACCESS_PUBLIC;
$group->briefdescription = elgg_echo('LTI:provision:group');
$consumer_instance = new LTI_Tool_Consumer_Instance($group->consumer_key, elgg_get_config('dbprefix'));
$context = new LTI_Context($consumer_instance, $group->context_id);
$group->description = $context->title;
$group->save();
$group->join($user);
// Add images
$prefix = 'groups/' . $group->guid;
$filename = GetImage($consumer_key, '.jpg');
$thumbtiny = get_resized_image_from_existing_file($filename, 25, 25, true);
$thumbsmall = get_resized_image_from_existing_file($filename, 40, 40, true);
$thumbmedium = get_resized_image_from_existing_file($filename, 100, 100, true);
$thumblarge = get_resized_image_from_existing_file($filename, 200, 200, false);
if ($thumbtiny) {
$thumb = new ElggFile();
$thumb->owner_guid = $group->owner_guid;
$thumb->setMimeType('image/jpeg');
$thumb->setFilename($prefix . "tiny.jpg");
$thumb->open("write");
$thumb->write($thumbtiny);
$thumb->close();
$thumb->setFilename($prefix . "small.jpg");
$thumb->open("write");
$thumb->write($thumbsmall);
$thumb->close();
$thumb->setFilename($prefix . "medium.jpg");
$thumb->open("write");
$thumb->write($thumbmedium);
$thumb->close();
$thumb->setFilename($prefix . "large.jpg");
$thumb->open("write");
$thumb->write($thumblarge);
$thumb->close();
$group->icontime = time();
}
// return the URL
return $group;
}
示例7: put
function put($url = '', $handle = null, $data = array())
{
if (!$url) {
return false;
}
$hash = md5($url);
$site = elgg_get_site_entity();
if (!$handle) {
$handle = $site->guid;
}
if (!empty($data)) {
$thumbnails = !empty($data['thumbnails']) ? $data['thumbnails'] : array();
$icons = !empty($data['icons']) ? $data['icons'] : array();
$thumbnails = array_merge($thumbnails, $icons);
if (!empty($thumbnails) && $this->config->get('cache_thumbnails')) {
foreach ($thumbnails as $thumbnail_url) {
$imagesize = getimagesize($thumbnail_url);
if (empty($imagesize) || $imagesize[0] < $this->config->get('cache_thumb_size_lower_threshold')) {
continue;
}
$post_max_size = elgg_get_ini_setting_in_bytes('post_max_size');
$upload_max_filesize = elgg_get_ini_setting_in_bytes('upload_max_filesize');
$max_upload = $upload_max_filesize > $post_max_size ? $post_max_size : $upload_max_filesize;
$filesize = filesize($thumbnail_url);
if (!$filesize || $filesize > $max_upload) {
continue;
}
$size = $this->config->get('cache_thumb_size');
$thumb = get_resized_image_from_existing_file($thumbnail_url, $size, $size, false, 0, 0, 0, 0, true);
if ($thumb) {
$file = new ElggFile();
$file->owner_guid = $site->guid;
$file->setFilename("scraper_cache/thumbs/{$hash}.{$handle}.jpg");
$file->open('write');
$file->write($thumb);
$file->close();
$data['thumb_cache'] = time();
break;
}
}
}
}
$file = new ElggFile();
$file->owner_guid = $site->guid;
$file->setFilename("scraper_cache/resources/{$hash}.{$handle}.json");
$file->open('write');
$file->write(json_encode($data));
$file->close();
return $data;
}
示例8: get_resized_image_from_uploaded_file
/**
* Gets the jpeg contents of the resized version of an uploaded image
* (Returns false if the uploaded file was not an image)
*
* @param string $input_name The name of the file input field on the submission form
* @param int $maxwidth The maximum width of the resized image
* @param int $maxheight The maximum height of the resized image
* @param bool $square If set to true, will take the smallest
* of maxwidth and maxheight and use it to set the
* dimensions on all size; the image will be cropped.
* @param bool $upscale Resize images smaller than $maxwidth x $maxheight?
*
* @return false|mixed The contents of the resized image, or false on failure
*/
function get_resized_image_from_uploaded_file($input_name, $maxwidth, $maxheight, $square = false, $upscale = false)
{
$files = _elgg_services()->request->files;
if (!$files->has($input_name)) {
return false;
}
$file = $files->get($input_name);
if (empty($file)) {
// a file input was provided but no file uploaded
return false;
}
if ($file->getError() !== 0) {
return false;
}
return get_resized_image_from_existing_file($file->getPathname(), $maxwidth, $maxheight, $square, 0, 0, 0, 0, $upscale);
}
示例9: uploadCK
function uploadCK($page, $identifier, $obj)
{
$funcNum2 = get_Input('CKEditorFuncNum', 'CKEditorFuncNum');
$file = new ElggFile();
$filestorename = strtolower(time() . $_FILES['upload']['name']);
$file->setFilename($filestorename);
$file->setMimeType($_FILES['upload']['type']);
$file->owner_guid = elgg_get_logged_in_user_guid();
$file->subtype = "file";
$file->originalfilename = $filestorename;
$file->access_id = ACCESS_PUBLIC;
$file->open("write");
$file->write(get_uploaded_file('upload'));
$file->close();
$result = $file->save();
if ($result) {
$master = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 550, 550);
if ($master !== false) {
$_SESSION['UPLOAD_DATA']['file_save'] = "started";
$filehandler = new ElggFile();
$filehandler->setFilename($filestorename);
$filehandler->setMimeType($_FILES['upload']['type']);
$filehandler->owner_guid = $user->guid;
$filehandler->subtype = "file";
$filehandler->originalfilename = $filestorename;
$filehandler->access_id = ACCESS_PUBLIC;
$filehandler->open("write");
$filehandler->write($master);
$filehandler->close();
$filehandler->save();
// Dev URL
$url = elgg_get_site_url() . 'CKEditorView?file_guid=' . $filehandler->guid;
//Production URL
//$url ='/CKEditorView?file_guid='.$filehandler->guid;
echo '<script type="text/javascript">
window.parent.CKEDITOR.tools.callFunction(' . $funcNum2 . ', "' . $url . '","");
</script>';
exit;
} else {
echo '<script type="text/javascript">
window.parent.CKEDITOR.tools.callFunction(' . $funcNum2 . ', "","");
</script>';
exit;
}
}
return true;
}
示例10: saveThumbnail
protected function saveThumbnail($image, $name)
{
try {
$thumbnail = get_resized_image_from_existing_file($image->getFilenameOnFilestore(), 60, 60, true);
} catch (Exception $e) {
return FALSE;
}
$thumb = new ElggFile();
$thumb->setMimeType('image/jpeg');
$thumb->access_id = $this->access_id;
$thumb->setFilename($name);
$thumb->open("write");
$thumb->write($thumbnail);
$thumb->save();
$image->thumbnail_guid = $thumb->getGUID();
if (!$thumb->getGUID()) {
$thumb->delete();
return FALSE;
}
return TRUE;
}
示例11: register_error
$return_value = $this->processFile($upload_video);
if (!file_exists($return_value->videofile)) {
register_error(elgg_echo('izap_videos:error:notUploaded'));
forward($_SERVER['HTTP_REFERER']);
exit;
}
$this->access_id = 0;
$this->videotype = $return_value->videotype;
if ($return_value->videofile) {
$this->videofile = $return_value->videofile;
}
if (empty($_FILES['upload_thumbnail']['name'])) {
if ($return_value->thumb) {
$this->orignal_thumb = $return_value->orignal_thumb;
$this->imagesrc = $return_value->thumb;
}
} else {
if ($_FILES['upload_thumbnail']['error'] == 0) {
$set_original_thumbnail = $this->getTmpPath('original_' . $_FILES['upload_thumbnail']['name']);
$this->setFilename($set_original_thumbnail);
$this->open("write");
$this->write(file_get_contents($_FILES['upload_thumbnail']['tmp_name']));
//set thumbnail size
$thumbnail = get_resized_image_from_existing_file($this->getFilenameOnFilestore(), 650, 500);
$set_thumb = $this->getTmpPath($_FILES['upload_thumbnail']['name']);
$this->setFilename($set_thumb);
$this->open("write");
$this->write($thumbnail);
$this->imagesrc = $set_thumb;
}
}
示例12: unset
$thumb->open("write");
$thumb->write($thumbnail);
$thumb->close();
$file->thumbnail = $prefix . "thumb" . $filestorename;
unset($thumbnail);
}
$thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 153, 153, true);
if ($thumbsmall) {
$thumb->setFilename($prefix . "smallthumb" . $filestorename);
$thumb->open("write");
$thumb->write($thumbsmall);
$thumb->close();
$file->smallthumb = $prefix . "smallthumb" . $filestorename;
unset($thumbsmall);
}
$thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 600, 600, false);
if ($thumblarge) {
$thumb->setFilename($prefix . "largethumb" . $filestorename);
$thumb->open("write");
$thumb->write($thumblarge);
$thumb->close();
$file->largethumb = $prefix . "largethumb" . $filestorename;
unset($thumblarge);
}
}
}
// make sure session cache is cleared
unset($_SESSION['uploadtitle']);
unset($_SESSION['uploaddesc']);
unset($_SESSION['uploadtags']);
unset($_SESSION['uploadaccessid']);
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:31,代码来源:upload.php
示例13: facebook_connect_update_user_avatar
/**
* Used to Pull in the latest avatar from facebook.
*
* @access public
* @param array $user
* @param string $file_location
* @return void
*/
function facebook_connect_update_user_avatar($user, $file_location)
{
$path = elgg_get_data_path();
$tempfile = $path . $user->getGUID() . 'img.jpg';
$imgContent = file_get_contents($file_location);
$fp = fopen($tempfile, "w");
fwrite($fp, $imgContent);
fclose($fp);
$sizes = array('topbar' => array(16, 16, TRUE), 'tiny' => array(25, 25, TRUE), 'small' => array(40, 40, TRUE), 'medium' => array(100, 100, TRUE), 'large' => array(200, 200, FALSE), 'master' => array(550, 550, FALSE));
$filehandler = new ElggFile();
$filehandler->owner_guid = $user->getGUID();
foreach ($sizes as $size => $dimensions) {
$image = get_resized_image_from_existing_file($tempfile, $dimensions[0], $dimensions[1], $dimensions[2]);
$filehandler->setFilename("profile/{$user->guid}{$size}.jpg");
$filehandler->open('write');
$filehandler->write($image);
$filehandler->close();
}
// update user's icontime
$user->icontime = time();
return TRUE;
}
示例14: implode
$metadata['location'] = implode(', ', $location);
}
// we have received a verified email from a provider
if ($verified) {
elgg_set_user_validation_status($new_user->guid, true, 'hybridauth');
}
foreach ($metadata as $md_name => $md_value) {
create_metadata($new_user->guid, $md_name, $md_value, '', $new_user->guid, ACCESS_PRIVATE, true);
}
if ($photo_url) {
$icon_sizes = elgg_get_config('icon_sizes');
$filehandler = new ElggFile();
$filehandler->owner_guid = $new_user->guid;
foreach ($icon_sizes as $size => $dimensions) {
$image = get_resized_image_from_existing_file($photo_url, $dimensions[0], $dimensions[1], $dimensions[2]);
$image = get_resized_image_from_existing_file($photo_url, $dimensions['w'], $dimensions['h'], $dimensions['square'], 0, 0, 0, 0, $dimensions['upscale']);
$filehandler->setFilename("profile/{$new_user->guid}{$size}.jpg");
$filehandler->open('write');
$filehandler->write($image);
$filehandler->close();
}
$new_user->icontime = time();
}
if ($provider && $provider_uid) {
elgg_set_plugin_user_setting("{$provider}:uid", $provider_uid, $new_user->guid, 'elgg_hybridauth');
elgg_trigger_plugin_hook('hybridauth:authenticate', $provider, array('entity' => $new_user));
}
$params = array_merge($params, $metadata);
// @todo should registration be allowed no matter what the plugins return?
if (!elgg_trigger_plugin_hook('register', 'user', $params, TRUE)) {
$ia = elgg_set_ignore_access(true);
示例15: processFile
/**
* Used to process the video file
* @param string $file upload file name
* @return object
*/
protected function processFile($file)
{
$returnValue = new stdClass();
$returnValue->type = 'uploaded';
$fileName = $_FILES[$file['mainArray']]['name'][$file['fileName']];
$error = $_FILES[$file['mainArray']]['error'][$file['fileName']];
$tmpName = $_FILES[$file['mainArray']]['tmp_name'][$file['fileName']];
$type = $_FILES[$file['mainArray']]['type'][$file['fileName']];
$size = $_FILES[$file['mainArray']]['size'][$file['fileName']];
// if error
if ($error > 0) {
return 104;
}
// if file is of zero size
if ($size == 0) {
return 105;
}
// check supported video type
if (!izapSupportedVideos_izap_videos($fileName)) {
return 106;
}
// check supported video size
if (!izapCheckFileSize_izap_videos($size)) {
return 107;
}
// upload the tmp file
$newFileName = izapGetFriendlyFileName_izap_videos($fileName);
$this->setFilename('tmp/' . $newFileName);
$this->open("write");
$this->write(file_get_contents($tmpName));
$returnValue->tmpFile = $this->getFilenameOnFilestore();
// take snapshot of the video
$image = new izapConvert($returnValue->tmpFile);
if ($image->photo()) {
$retValues = $image->getValues(true);
if ($retValues['imagename'] != '' && $retValues['imagecontent'] != '') {
$this->setFilename('izap_videos/uploaded/' . $retValues['imagename']);
$this->open("write");
if ($this->write($retValues['imagecontent'])) {
$orignal_file_path = $this->getFilenameOnFilestore();
$thumb = get_resized_image_from_existing_file($orignal_file_path, 120, 90);
$this->setFilename('izap_videos/uploaded/' . $retValues['imagename']);
$this->open("write");
$this->write($thumb);
$this->close();
$returnValue->thumb = 'izap_videos/uploaded/' . $retValues['imagename'];
// Defining new preview attribute of standard object
$returnValue->preview_400 = 'izap_videos/uploaded/preview_400';
$returnValue->preview_200 = 'izap_videos/uploaded/preview_200';
}
}
}
// check if it is flv, then dont send it to queue
if (izap_get_file_extension($returnValue->tmpFile) == 'flv') {
$file_name = 'izap_videos/uploaded/' . $newFileName;
$this->setFilename($file_name);
$this->open("write");
$this->write(file_get_contents($returnValue->tmpFile));
$this->converted = 'yes';
$this->videofile = $file_name;
$this->orignalfile = $file_name;
$returnValue->is_flv = 'yes';
// remove the tmp file
@unlink($returnValue->tmpFile);
}
return $returnValue;
}