本文整理匯總了PHP中Imagick::getImageGeometry方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::getImageGeometry方法的具體用法?PHP Imagick::getImageGeometry怎麽用?PHP Imagick::getImageGeometry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagick
的用法示例。
在下文中一共展示了Imagick::getImageGeometry方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: mkbilder
function mkbilder()
{
$this->err->write('mkbilder', 'IN');
if (!class_exists("Imagick")) {
$this->err->out("Imagick-Extention nicht installiert", true);
return false;
}
$handle = new Imagick();
if (!$handle->readImage("./tmp/tmp.file_org")) {
return false;
}
$d = $handle->getImageGeometry();
if ($d["width"] < $d["height"]) {
$faktor = $d["height"] / $d["width"];
} else {
$faktor = $d["width"] / $d["height"];
}
$thumbheight = floor($this->thumbwidth * $faktor);
$handle->thumbnailImage($this->thumbwidth, $thumbheight);
$rc = $handle->writeImage("./tmp/tmp.file_thumb");
$handle->readImage("./tmp/tmp.file_org");
$popupheight = floor($this->popupwidth * $faktor);
$handle->thumbnailImage($this->popupwidth, $popupheight);
$rc = $handle->writeImage("./tmp/tmp.file_popup");
$handle->readImage("./tmp/tmp.file_org");
$infoheight = floor($this->infowidth * $faktor);
$handle->thumbnailImage($this->infowidth, $infoheight);
$rc = $handle->writeImage("./tmp/tmp.file_info");
return $rc;
}
示例2:
function post_resource($data)
{
if ($this->storage->dir->exists) {
return so_output::conflict('Image already exists');
}
$this->storage->dir->exists = true;
$image = new \Imagick((string) $data['file']);
$image->writeImage((string) $this->fileOrinal);
$size = $image->getImageGeometry();
if ($size['width'] > 800 or $size['height'] > 600) {
$image->adaptiveResizeImage(800, 600, true);
}
$image->writeImage((string) $this->fileMaximal);
$size = $image->getImageGeometry();
if ($size['width'] > 100 or $size['height'] > 100) {
$image->adaptiveResizeImage(100, 100, true);
}
$image->writeImage((string) $this->filePreview);
return so_output::ok()->content($this->model);
}
示例3: get_image_size
function get_image_size($fn)
{
// try gd
if (function_exists('getimagesize')) {
$ret = @getimagesize($fn);
if ($ret !== false) {
return array('width' => $ret[0], 'height' => $ret[1], 'mime' => $ret['mime']);
}
}
// try imagemagick
if (extension_loaded('imagick')) {
try {
$im = new Imagick($fn);
return $im->getImageGeometry();
} catch (Exception $e) {
}
}
// XXX: use bin?
return false;
}
示例4: load
public function load($path)
{
if (file_exists($path)) {
$this->originImage = new \Imagick($path);
$this->originGeo = $this->originImage->getImageGeometry();
print_r($this->originGeo);
} else {
throw new \Exception("File {$path} doesn't exists", 404);
}
}
示例5: Imagick
function imagick_thumbnail($image, $timage, $ext, $thumbnail_name, $imginfo)
{
try {
$imagick = new Imagick();
$fullpath = "./" . $this->thumbnail_path . "/" . $timage[0] . "/" . $thumbnail_name;
if ($ext == "gif") {
$imagick->readImage($image . '[0]');
} else {
$imagick->readImage($image);
}
$info = $imagick->getImageGeometry();
$this->info[0] = $info['width'];
$this->info[1] = $info['height'];
$imagick->thumbnailImage($this->dimension, $this->dimension, true);
if ($ext == "png" || $ext == "gif") {
$white = new Imagick();
$white->newImage($this->dimension, $this->dimension, "white");
$white->compositeimage($image, Imagick::COMPOSITE_OVER, 0, 0);
$white->writeImage($fullpath);
$white->clear();
} else {
$imagick->writeImage($fullpath);
}
$imagick->clear();
} catch (Exception $e) {
echo "Unable to load image." . $e->getMessage();
return false;
}
return true;
}
示例6: getSizesWhen
public function getSizesWhen($sizeString)
{
$size = $this->getModule()->parseSize($sizeString);
if (!$size) {
throw new \Exception('Bad size..');
}
if ($this->getModule()->graphicsLibrary == 'Imagick') {
$image = new \Imagick($this->getPathToOrigin());
$sizes = $image->getImageGeometry();
} else {
$image = new \abeautifulsite\SimpleImage($this->getPathToOrigin());
$sizes['width'] = $image->get_width();
$sizes['height'] = $image->get_height();
}
$imageWidth = $sizes['width'];
$imageHeight = $sizes['height'];
$newSizes = [];
if (!$size['width']) {
$newWidth = $imageWidth * ($size['height'] / $imageHeight);
$newSizes['width'] = intval($newWidth);
$newSizes['heigth'] = $size['height'];
} elseif (!$size['height']) {
$newHeight = intval($imageHeight * ($size['width'] / $imageWidth));
$newSizes['width'] = $size['width'];
$newSizes['heigth'] = $newHeight;
}
return $newSizes;
}
示例7: post
public function post()
{
if ($this->validate()) {
$image = new PhotoActiveRecord();
$image->userId = Yii::$app->user->identity->id;
$image->name = $this->name . '';
$image->photo = file_get_contents($this->file->tempName);
$image->posted = date('Y-m-d H-i-s');
$imagick = new \Imagick();
$imagick->readImageBlob($image->photo);
$size = $imagick->getImageGeometry();
if ($size['width'] > 800) {
foreach ($imagick as $frame) {
$frame->thumbnailImage(800, 0);
}
}
$image->thumbnail = $imagick->getImagesBlob();
if (!$image->save()) {
return false;
}
$tags = split(',', $this->tags);
foreach ($tags as $item) {
if ($item != '') {
$tag = new TagsActiveRecord();
$tag->photo = $image->id;
$tag->tag = trim($item);
if (!$tag->save()) {
return false;
}
}
}
return true;
}
return false;
}
示例8: resize
public function resize($file, $size = array('width' => 100, 'height' => 100), $type = 'png', $fixed = false)
{
$image = new Imagick($this->file);
$image->setBackgroundColor(new ImagickPixel('transparent'));
$image->setImageFormat($type);
if ($fixed === true) {
$newWidth = $size['width'];
$newHeight = $size['height'];
} else {
$imageprops = $image->getImageGeometry();
$width = $imageprops['width'];
$height = $imageprops['height'];
if ($width > $height) {
$newHeight = $size['height'];
$newWidth = $size['height'] / $height * $width;
} else {
$newWidth = $size['width'];
$newHeight = $size['width'] / $width * $height;
}
}
$image->resizeImage($newWidth, $newHeight, imagick::FILTER_LANCZOS, 1);
$image->writeImage($file . '.' . $type);
$image->clear();
$image->destroy();
}
示例9: getCenterOffset
/**
* Get the cropping offset for the image based on the center of the image
*
* @param \Imagick $image
* @param int $targetWidth
* @param int $targetHeight
* @return array
*/
protected function getCenterOffset(\Imagick $image, $targetWidth, $targetHeight)
{
$size = $image->getImageGeometry();
$originalWidth = $size['width'];
$originalHeight = $size['height'];
$goalX = (int) (($originalWidth - $targetWidth) / 2);
$goalY = (int) (($originalHeight - $targetHeight) / 2);
return array('x' => $goalX, 'y' => $goalY);
}
示例10: isWQXGAFile
function isWQXGAFile($filename)
{
try {
$image = new Imagick($filename);
$data = $image->getImageGeometry();
} catch (ImagickException $e) {
}
return !empty($data) && $data['width'] == 2560 && $data['height'] == 1600;
}
示例11: inscribeImageIntoCanvas
private function inscribeImageIntoCanvas(\Imagick $image) : \Imagick
{
$dimensions = $image->getImageGeometry();
$x = (int) round(($this->width - $dimensions['width']) / 2);
$y = (int) round(($this->height - $dimensions['height']) / 2);
$canvas = new \Imagick();
$canvas->newImage($this->width, $this->height, $this->backgroundColor, $image->getImageFormat());
$canvas->compositeImage($image, \Imagick::COMPOSITE_OVER, $x, $y);
return $canvas;
}
開發者ID:lizards-and-pumpkins,項目名稱:lib-image-processing-imagick,代碼行數:10,代碼來源:ImageMagickInscribeStrategy.php
示例12: resize
/**
* Returns a resized \Imagick object
*
* If you want to know more on the various methods available to resize an
* image, check out this link : @link https://stackoverflow.com/questions/8517304/what-the-difference-of-sample-resample-scale-resize-adaptive-resize-thumbnail-im
*
* @param \Imagick $bp
* @param int $maxX
* @param int $maxY
*
* @return \Imagick
*/
private function resize($bp, $maxX, $maxY)
{
list($previewWidth, $previewHeight) = array_values($bp->getImageGeometry());
// We only need to resize a preview which doesn't fit in the maximum dimensions
if ($previewWidth > $maxX || $previewHeight > $maxY) {
// TODO: LANCZOS is the default filter, CATROM could bring similar results faster
$bp->resizeImage($maxX, $maxY, imagick::FILTER_LANCZOS, 1, true);
}
return $bp;
}
示例13: render
function render()
{
$imagick = new \Imagick(realpath($this->imageControl->getImagePath()));
$output = "The values of getImageGeometry for the image below are:\n";
foreach ($imagick->getImageGeometry() as $key => $value) {
$output .= "{$key} : {$value}\n";
}
$output = nl2br($output);
$output .= $this->renderImageURL();
return $output;
}
示例14: compare
/**
* This function compared two images
*
* @param Imagick $image1
* @param Imagick $image2
* @return ComparisonResult
*/
public function compare(\Imagick $image1, \Imagick $image2)
{
$imagick1Size = $image1->getImageGeometry();
$imagick2Size = $image2->getImageGeometry();
$maxWidth = max($imagick1Size['width'], $imagick2Size['width']);
$maxHeight = max($imagick1Size['height'], $imagick2Size['height']);
$image1->extentImage($maxWidth, $maxHeight, 0, 0);
$image2->extentImage($maxWidth, $maxHeight, 0, 0);
$result = $image1->compareImages($image2, \Imagick::METRIC_MEANSQUAREERROR);
$result[0]->setImageFormat('png');
return new ComparisonResult(round($result[1] * 100, 2), $image1, $image2, $result[0]);
}
示例15: getSizes
public function getSizes()
{
$sizes = false;
if ($this->getModule()->graphicsLibrary == 'Imagick') {
$image = new \Imagick($this->getPathToOrigin());
$sizes = $image->getImageGeometry();
} else {
$image = new \abeautifulsite\SimpleImage($this->getPathToOrigin());
$sizes['width'] = $image->get_width();
$sizes['height'] = $image->get_height();
}
return $sizes;
}