本文整理汇总了PHP中Thumbnail::createThumbnail方法的典型用法代码示例。如果您正苦于以下问题:PHP Thumbnail::createThumbnail方法的具体用法?PHP Thumbnail::createThumbnail怎么用?PHP Thumbnail::createThumbnail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thumbnail
的用法示例。
在下文中一共展示了Thumbnail::createThumbnail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processImgUpload
protected function processImgUpload()
{
//if no errors are found
$thumbnail = new Thumbnail();
if (is_uploaded_file($this->Filetemp_name)) {
//$this->Filename = rename($this->Filename,$upload_time."_".$this->Filename);
$tmploc = move_uploaded_file($this->Filetemp_name, $this->Temp_dir . $this->Filename);
if ($tmploc) {
$thumbnail->createThumbnail($this->Temp_dir . $this->Filename, $this->Thumb_dir . $this->Filename, self::MAX_THUMB_WIDTH, self::MAX_THUMB_HEIGHT);
$thumbnail->createThumbnail($this->Temp_dir . $this->Filename, $this->Upload_dir . $this->Filename, self::MAX_IMG_WIDTH, self::MAX_IMG_HEIGHT);
list($new_width, $new_height) = getimagesize($this->Upload_dir . $this->Filename);
$this->Newfilename = $this->getFilename($this->Filename, ".");
$this->File_ext = $this->get_file_extension($this->Filename);
$this->Filesize = $this->Filesize;
$this->Width = $new_width;
$this->Height = $new_height;
$this->Filetype;
}
$this->deleteFile($this->Temp_dir . $this->Filename);
}
}
示例2: Thumbnail
if (!is_file($fullpath)) {
js_fail("File {$fullpath} does not exist.");
}
$imgInfo = @getImageSize($fullpath);
//Not an image, bail out.
if (!is_array($imgInfo)) {
js_fail("File {$fullpath} is not an image.");
}
if (!isset($_GET['to'])) {
$resized = $manager->getResizedName($fullpath, $_GET['width'], $_GET['height']);
$_GET['to'] = $manager->getResizedName($image, $_GET['width'], $_GET['height'], FALSE);
} else {
$resized = Files::makeFile($manager->getImagesDir(), $_GET['to']);
}
// Check to see if it already exists
if (is_file($resized)) {
// And is newer
if (filemtime($resized) >= filemtime($fullpath)) {
js_success($_GET['to']);
}
}
// resize (thumbnailer will do this for us just fine)
$thumbnailer = new Thumbnail($_GET['width'], $_GET['height']);
$thumbnailer->proportional = FALSE;
$thumbnailer->createThumbnail($fullpath, $resized);
// did it work?
if (is_file($resized)) {
js_success($_GET['to']);
} else {
js_fail("Resize Failed.");
}
示例3: header
}
//if the image is less than the thumbnail dimensions
//send the original image as thumbnail
if ($imgInfo[0] <= $IMConfig['thumbnail_width'] && $imgInfo[1] <= $IMConfig['thumbnail_height']) {
header('Location: ' . $manager->getFileURL($image));
exit;
}
//Check for thumbnails
$thumbnail = $manager->getThumbName($fullpath);
if (is_file($thumbnail)) {
//if the thumbnail is newer, send it
if (filemtime($thumbnail) >= filemtime($fullpath)) {
header('Location: ' . $manager->getThumbURL($image));
exit;
}
}
//creating thumbnails
$thumbnailer = new Thumbnail($IMConfig['thumbnail_width'], $IMConfig['thumbnail_height']);
$thumbnailer->createThumbnail($fullpath, $thumbnail);
//Check for NEW thumbnails
if (is_file($thumbnail)) {
//send the new thumbnail
header('Location: ' . $manager->getThumbURL($image));
exit;
} else {
//show the default image, otherwise we quit!
$default = $manager->getDefaultThumb();
if ($default) {
header('Location: ' . $default);
}
}
示例4: createThumbnail
/**
* creates the thumbnail and saves it to a variable
*
* @return void
* @uses Thumbnail::createThumbnail()
* @uses readWMImage()
* @uses $thumbnail
* @uses $thumbnail_width
* @uses $thumbnail_height
* @uses $wm_image_width
* @uses $wm_image_height
* @uses $position
* @uses $wm_image
* @uses $logos
*/
protected function createThumbnail()
{
parent::createThumbnail();
imagealphablending($this->thumbnail, true);
foreach ($this->logos as $logo) {
if (strlen(trim($logo['path'])) > 0) {
$this->readWMImage($logo['path']);
$start_pos_x = $this->thumbnail_width - $logo['margin'] - $this->wm_image_width;
$start_pos_y = $this->thumbnail_height - $logo['margin'] - $this->wm_image_height;
switch ($logo['pos']) {
case 1:
// left-top
imagecopy($this->thumbnail, $this->wm_image, $logo['margin'], $logo['margin'], 0, 0, $this->wm_image_width, $this->wm_image_height);
break;
case 2:
// right-top
imagecopy($this->thumbnail, $this->wm_image, $start_pos_x, $logo['margin'], 0, 0, $this->wm_image_width, $this->wm_image_height);
break;
case 3:
// right-bottom
imagecopy($this->thumbnail, $this->wm_image, $start_pos_x, $start_pos_y, 0, 0, $this->wm_image_width, $this->wm_image_height);
break;
case 4:
// left-bottom
imagecopy($this->thumbnail, $this->wm_image, $logo['margin'], $start_pos_y, 0, 0, $this->wm_image_width, $this->wm_image_height);
break;
case 5:
// center
// center
default:
$middle_x = ($this->thumbnail_width >> 1) - ($this->wm_image_width >> 1);
$middle_y = ($this->thumbnail_height >> 1) - ($this->wm_image_height >> 1);
imagecopy($this->thumbnail, $this->wm_image, $middle_x, $middle_y, 0, 0, $this->wm_image_width, $this->wm_image_height);
break;
}
// end switch
unset($this->wm_image);
}
// end if
}
// end foreach
}