本文整理匯總了PHP中Imagick::getimageblob方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::getimageblob方法的具體用法?PHP Imagick::getimageblob怎麽用?PHP Imagick::getimageblob使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagick
的用法示例。
在下文中一共展示了Imagick::getimageblob方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: IMAGEN_tipo_normal
function IMAGEN_tipo_normal()
{
$escalado = 'IMG/i/m/' . $_GET['ancho'] . '_' . $_GET['alto'] . '_' . $_GET['sha1'];
$origen = 'IMG/i/' . $_GET['sha1'];
$ancho = $_GET['ancho'];
$alto = $_GET['alto'];
if (@($ancho * $alto) > 562500) {
die('La imagen solicitada excede el límite de este servicio');
}
if (!file_exists($escalado)) {
$im = new Imagick($origen);
$im->setCompression(Imagick::COMPRESSION_JPEG);
$im->setCompressionQuality(85);
$im->setImageFormat('jpeg');
$im->stripImage();
$im->despeckleImage();
$im->sharpenImage(0.5, 1);
//$im->reduceNoiseImage(0);
$im->setInterlaceScheme(Imagick::INTERLACE_PLANE);
$im->resizeImage($ancho, $alto, imagick::FILTER_LANCZOS, 1);
$im->writeImage($escalado);
$im->destroy();
}
$im = new Imagick($escalado);
$output = $im->getimageblob();
$outputtype = $im->getFormat();
$im->destroy();
header("Content-type: {$outputtype}");
header("Content-length: " . filesize($escalado));
echo $output;
}
示例2: setImage
public function setImage(\Imagick $image, $identifier)
{
$url = $this->getStorageFile($identifier);
$ch = curl_init();
$imageContent = base64_encode($image->getimageblob());
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "image=" . $imageContent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
var_dump($server_output);
curl_close($ch);
}
示例3: phorum_api_image_thumbnail
//.........這裏部分代碼省略.........
$scale_w = $max_w / $img['cur_w'];
}
// Need vertical scaling?
if ($max_h !== NULL && $max_h < $img['cur_h']) {
$scale_h = $max_h / $img['cur_h'];
}
// No scaling needed, return.
if ($scale_w === NULL && $scale_h === NULL) {
return $img;
}
// The lowest scale factor wins. Compute the required image size.
if ($scale_h === NULL || $scale_w !== NULL && $scale_w < $scale_h) {
$img['new_w'] = $max_w;
$img['new_h'] = floor($img['cur_h'] * $scale_w + 0.5);
} else {
$img['new_w'] = floor($img['cur_w'] * $scale_h + 0.5);
$img['new_h'] = $max_h;
}
// -----------------------------------------------------------------
// Try to use the imagick library tools
// -----------------------------------------------------------------
// First, try to load the imagick extension if it is not loaded yet.
// This way we can make this work on systems where imagick is not built-in
// or loaded from the PHP ini.
if (($method === NULL || $method == 'imagick') && !extension_loaded('imagick')) {
@dl('imagick.so');
}
if (($method === NULL || $method == 'imagick') && extension_loaded('imagick') && class_exists('Imagick')) {
$method = NULL;
$imagick = new Imagick();
$imagick->readImageBlob($image);
$imagick->thumbnailImage($img['new_w'], $img['new_h'], TRUE);
$imagick->setFormat("jpg");
$img['image'] = $imagick->getimageblob();
$img['new_mime'] = 'image/' . $imagick->getFormat();
$img['method'] = 'imagick';
return $img;
}
// -----------------------------------------------------------------
// Try to use the GD library tools
// -----------------------------------------------------------------
// First, try to load the GD extension if it is not loaded yet.
// This way we can make this work on systems where gd is not built-in
// or loaded from the PHP ini.
if (($method === NULL || $method == 'gd') && !extension_loaded('gd')) {
@dl('gd.so');
}
if (($method === NULL || $method == 'gd') && extension_loaded('gd') && function_exists('gd_info')) {
// We need gd_info() to check whether GD has the required
// image support for the type of image that we are handling.
$gd = gd_info();
// We need PNG support for the scaled down image.
if (empty($gd['PNG Support'])) {
$error = "GD: no PNG support available for creating thumbnail";
} elseif ($type == 'gif' && empty($gd['GIF Read Support']) || $type == 'jpeg' && empty($gd['JPG Support']) || $type == 'png' && empty($gd['PNG Support'])) {
$error = "GD: no support available for image type \"{$type}\"";
} else {
// Create a GD image handler based on the image data.
// imagecreatefromstring() spawns PHP warnings if the file cannot
// be processed. We do not care to see that in the event logging,
// so if event logging is loaded, we suspend it here.
// Instead, we catch error output and try to mangle it into a
// usable error message.
if (defined('EVENT_LOGGING')) {
phorum_mod_event_logging_suspend();
}
示例4: getImageAction
/**
* @Route("/{id}/image/{image_id}", name="activity_image")
* @Method("GET")
*/
public function getImageAction($id, $image_id, Request $request)
{
$width = $request->query->get("width");
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('OesteveGrupetaBundle:Activity')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
}
$authChecker = $this->get('security.authorization_checker');
if (false === $authChecker->isGranted(ActivityVoter::VIEW, $entity)) {
throw $this->createAccessDeniedException('Unauthorized access!');
}
$image = $em->getRepository('OesteveGrupetaBundle:Image')->find($image_id);
if (!$image_id) {
throw $this->createNotFoundException('Unable to find Imagen entity.');
}
$fileContent = base64_decode($image->getContent());
if ($width != null) {
$tmpDir = $this->container->getParameter('tmp_dir');
$cachedDirName = $tmpDir . '/activities/';
$cachedFileName = $cachedDirName . '/img_' . $width . '_' . $image->getId();
if (!file_exists($cachedDirName)) {
mkdir($cachedDirName, 0777, TRUE);
}
if (file_exists($cachedFileName)) {
$fileContent = file_get_contents($cachedFileName);
} else {
$img = new \Imagick();
$img->readimageblob($fileContent);
//Hacer una miniatura de una imagen cargada. 0 para los ejes preserva la proporción de aspecto
$img->thumbnailImage($width, 0);
$fileContent = $img->getimageblob();
if ($tmpDir != null) {
file_put_contents($cachedFileName, $fileContent);
}
}
}
$f = finfo_open();
$mime_type = finfo_buffer($f, $fileContent, FILEINFO_MIME_TYPE);
$response = new Response();
$response->headers->set('Content-Type', $mime_type);
$response->headers->set('Expires', 0);
$response->headers->set('Cache-Control', 'must-revalidate');
$response->headers->set('Pragma', 'public');
$response->headers->set('Content-length', strlen($fileContent));
$response->setContent($fileContent);
return $response;
}
示例5: renderImage
function renderImage()
{
$imagick = new \Imagick(realpath("imagick/images/Biter_500.jpg"));
//$imagick->setOption('jpeg:extent', '20kb');
//$imagick->setcompressionquality(30);
$imagick->setimagecompressionquality(30);
header("Content-Type: image/jpg");
echo $imagick->getimageblob();
}
示例6: fnOnTheFlyImageResize
/**
* Function resize the Image on the fly with Imagemagick
*
* @param sting $strSrc
* @param sting $intHeight
* @param sting $intWidth
*
*/
function fnOnTheFlyImageResize($strSrc, $intHeight, $intWidth)
{
$strImageSrc = $strSrc;
$strImageH = $intHeight;
$strImageW = $intWidth;
if (substr(trim($strImageSrc), 0, 4) == "http") {
// SITENAME
$strImageSrc = str_replace(SITE_NAME . "/", "", $strImageSrc);
if (substr(trim($strImageSrc), 0, 4) == "user") {
// NOT BSE64 DEODED
$strImageSrc = base64_encode($strImageSrc);
}
if (substr(trim($strImageSrc), 0, 9) == "editorial") {
// NOT BSE64 DEODED
$strImageSrc = base64_encode($strImageSrc);
}
} elseif (substr(trim($strImageSrc), 0, 4) == "user") {
// NOT BSE64 DEODED
$strImageSrc = base64_encode($strImageSrc);
} elseif (substr(trim($strImageSrc), 0, 5) == "/user") {
// NOT BSE64 DEODED
$strImageSrc = substr_replace("/", '', 0, 1);
$strImageSrc = base64_encode($strImageSrc);
}
if (!$strImageH) {
$strImageH = "70";
}
if (!$strImageW) {
$strImageW = "70";
}
if ($strImageSrc != "") {
// Decode image from base64
$image = base64_decode($strImageSrc);
//$image=$strImageSrc;
// Create Imagick object
$im = new Imagick();
// Convert image into Imagick
$im->readImage(DOCUMENT_ROOT . "/" . $image);
//$im->readImage($image);
// Create thumbnail max of 200x82
$im->thumbnailImage($strImageW, $strImageH, true);
// Add a subtle border
$color = new ImagickPixel();
$color->setColor("rgb(220,220,220)");
$im->borderImage($color, 1, 1);
// Output the image
$output = $im->getimageblob();
$outputtype = $im->getFormat();
// unset($im);
header("Content-type: {$outputtype}");
print $output;
}
}
示例7: nonImageAddTexte
static function nonImageAddTexte($text, $fontfile, $fontsize)
{
$svg = '<?xml version="1.0" encoding="utf-8"?>
<!-- The icon can be used freely in both personal and commercial projects with no attribution required, but always appreciated.
You may NOT sub-license, resell, rent, redistribute or otherwise transfer the icon without express written permission from iconmonstr.com -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="512px" height="512px" viewBox="0 0 512 512" xml:space="preserve">
<defs>
<linearGradient id="degrade" x1="100%" y1="0" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#898989; stop-opacity:0.2;"/>
<stop offset="40%" style="stop-color:#464646; stop-opacity:1;"/>
<stop offset="100%" style="stop-color:#111111; stop-opacity:0.7;"/>
</linearGradient>
<linearGradient id="degrade1" x1="100%" y1="0" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#111111; stop-opacity:0.7;"/>
<stop offset="40%" style="stop-color:#AAAAAA; stop-opacity:1;"/>
<stop offset="100%" style="stop-color:#F0F0F0; stop-opacity:0.2;"/>
</linearGradient>
<style type="text/css">
#stop1{ stop-color:chartreuse; stop-opacity:0.2; } #stop2{ stop-color:cornflowerblue; stop-opacity:1; } #stop3{ stop-color:chartreuse; stop-opacity:0.7; }
</style>
</defs>
<path style="fill:url(#degrade); stroke:#BBBBBB; stroke-width:2px;" id="video-icon" d="M50,60.345v391.311h412V60.345H50z M137.408,410.862H92.354v-38.747h45.055V410.862z M137.408,343.278
H92.354v-38.747h45.055V343.278z M137.408,275.372H92.354v-38.747h45.055V275.372z M137.408,208.111H92.354v-38.748h45.055V208.111z
M137.408,140.526H92.354v-38.747h45.055V140.526z M337.646,410.862H177.961V275.694h159.685V410.862z M337.646,236.947H177.961
V101.779h159.685V236.947z M423.253,410.862h-45.054v-38.747h45.054V410.862z M423.253,343.278h-45.054v-38.747h45.054V343.278z
M423.253,275.372h-45.054v-38.747h45.054V275.372z M423.253,208.111h-45.054v-38.748h45.054V208.111z M423.253,140.526h-45.054
v-38.747h45.054V140.526z"/>
</svg>
';
$im2 = new \Imagick();
$im2->setBackgroundColor(new \ImagickPixel('transparent'));
$im2->readimageblob($svg);
$im2->setImageFormat("png");
$im2->adaptiveResizeImage(140, 140);
/*Optional, if you need to resize*/
//return $im2->getimageblob();
$im = new \Imagick();
$im->newimage(260, 300, new \ImagickPixel('#999999'), "jpeg");
$im->compositeimage($im2, \Imagick::COMPOSITE_DEFAULT, 60, 80);
$widthmax = $im->getImageGeometry()["width"];
$draw = new \ImagickDraw();
/* On commence un nouveau masque nommé "gradient" */
$draw->setFillColor('#FFFFFF');
/* Font properties */
$draw->setFont($fontfile);
$draw->setFontSize($fontsize);
$draw->setGravity(\Imagick::GRAVITY_NORTH);
$words = explode(' ', $text);
//Test si la fontsize n'est pas trop grosse pour un mot
$i = 0;
while ($i < count($words)) {
$lineSize = $im->queryfontmetrics($draw, $words[$i])["textWidth"];
if ($lineSize < $widthmax) {
$i++;
} else {
$fontsize--;
$draw->setFontSize($fontsize);
}
}
$res = $words[0];
for ($i = 1; $i < count($words); $i++) {
$lineSize = $im->queryfontmetrics($draw, $res . " " . $words[$i]);
if ($lineSize["textWidth"] < $widthmax) {
$res .= " " . $words[$i];
} else {
$res .= "\n" . $words[$i];
}
}
/* Create text */
$im->annotateImage($draw, 0, 0, 0, $res);
return $im->getimageblob();
}
示例8: renderImage
public function renderImage()
{
$imagick = new \Imagick(realpath("images/fnord.png"));
header("Content-Type: image/png");
echo $imagick->getimageblob();
}
示例9: indexAction
/**
* 提供外部文件下載服務
*/
public function indexAction()
{
$id = $this->params()->fromRoute('id', null);
$download = $this->params()->fromRoute('d', false);
$resize = $this->params()->fromRoute('r', false);
$thumbnail = $this->params()->fromRoute('t', false);
$adpter = $this->params()->fromRoute('a', false);
$width = intval($this->params()->fromRoute('w', 0));
$height = intval($this->params()->fromRoute('h', 0));
$quality = intval($this->params()->fromRoute('q', 100));
if ($id == null) {
header("HTTP/1.1 404 Not Found");
return $this->response;
}
$gridFsFile = $this->_file->getGridFsFileById($id);
if ($gridFsFile instanceof \MongoGridFSFile) {
if (strpos(strtolower($gridFsFile->file['mime']), 'image') !== false) {
// 圖片處理
$fileInfo = $gridFsFile->file;
$fileName = $fileInfo['filename'];
$fileMime = $fileInfo['mime'];
$imagick = new \Imagick();
$resource = $gridFsFile->getResource();
$imagick->readImageFile($resource);
if ($adpter) {
$imagick->cropThumbnailImage($width, $height);
} elseif ($thumbnail) {
$imagick->thumbnailImage($width, $height);
} else {
$geo = $imagick->getImageGeometry();
$sizeWidth = $geo['width'];
$sizeHeight = $geo['height'];
if ($width > 0 && $height > 0) {
if ($sizeWidth / $width > $sizeHeight / $height) {
$height = 0;
} else {
$width = 0;
}
$imagick->thumbnailImage($width, $height);
} else {
if ($width > 0 || $height > 0) {
$imagick->thumbnailImage($width, $height);
}
}
}
if ($quality < 100) {
$imagick->setImageCompression(\Imagick::COMPRESSION_JPEG);
$imagick->setImageCompressionQuality($quality);
$fileName .= '.jpg';
$fileMime = 'image/jpg';
}
$imagick->stripImage();
$data = $imagick->getimageblob();
$imagick->destroy();
setHeaderExpires();
if (isset($fileMime)) {
header('Content-Type: ' . $fileMime . ';');
}
if ($download) {
header('Content-Disposition:attachment;filename="' . $fileName . '"');
} else {
header('Content-Disposition:filename="' . $fileName . '"');
}
echo $data;
} else {
$this->_file->output($gridFsFile, true, $download == null ? false : true);
}
return $this->response;
} else {
header("HTTP/1.1 404 Not Found");
return $this->response;
}
}
示例10: header
header('Content-Disposition: attachment; filename="shield.png"');
header('Content-Type: image/png');
echo $im->getimageblob();
break;
}
} else {
switch ($options['outputFormat']) {
case 'jpg':
$im = new Imagick();
$im->readimageblob($output);
$im->setimageformat('jpeg');
$im->setimagecompressionquality(90);
// $im->scaleimage(1000,1200);
header('Content-Type: image/jpg');
echo $im->getimageblob();
break;
case 'png':
$im = new Imagick();
$im->readimageblob($output);
$im->setimageformat('png');
// $im->scaleimage(1000,1200);
header('Content-Type: image/png');
echo $im->getimageblob();
break;
default:
case 'svg':
header('Content-Type: text/xml; charset=utf-8');
echo $output;
break;
}
}
示例11: getConvertData
/**
* Convert datas Format IN > Format OUT.
*
* @param string $format
*
* @throws \Exception
*
* @return string
*/
public function getConvertData($format)
{
$datas = null;
try {
$im = new \Imagick();
$im->readimageblob($this->data);
$im->setiteratorindex($this->page - 1);
$im->setImageFormat($format);
$datas = $im->getimageblob();
} catch (\ImagickException $e) {
$page_opt = null !== $this->page ? sprintf('-e PageRange=%d-%d', $this->page, $this->page) : '';
$uniq_name = $this->tmp . uniqid('UNO');
$actual_file = sprintf('%s.%s', $uniq_name, $this->format ?: 'tmp');
if (!is_dir($this->tmp)) {
throw new \Exception('Directory tmp is not exist');
}
try {
$process = $this->getProcess();
$process->setCmd(sprintf('cat - > %s && unoconv %s -f %s --stdout %s', $actual_file, $page_opt, $format, $actual_file))->setInput($this->data);
$datas = $process->run();
} catch (ProcessException $e) {
$process = $this->getProcess();
$process->setCmd(sprintf('cat - > %s && unoconv %s -f pdf %s && unoconv -f %s --stdout %s.pdf', $actual_file, $page_opt, $actual_file, $format, $uniq_name))->setInput($this->data);
$datas = $process->run();
}
$process = $this->getProcess();
$process->setCmd(sprintf('rm -f %s.*', $uniq_name))->run();
}
return $datas;
}
示例12: Imagick
\t\tl-2.501,1.094l-2.03,1.25l-1.564-0.156l-1.876-1.25l-6.095,0.156l-3.125,0.469l-3.907,1.25l-4.218,1.406l-2.814,1.719"/>
\t<path id="OH_Great_Lakes" fill="none" stroke="#000000" stroke-width="2" d="M751.406,340.469l-7.03,3.593l-3.751,2.188
\t\tl-3.281,3.594l-3.907,3.75l-3.125,0.781l-2.812,0.469l-5.313,2.5l-2.03,0.156l-3.281-2.969l-5,0.625l-2.501-1.406l-2.656-1.406"/>
\t<path id="IL_Great_Lakes" fill="none" stroke="#000000" stroke-width="2" d="M642.5,359.687l-1.249-0.781l-0.785-2.5l-1.248-3.594
\t\tl-1.565-1.719l-1.406-2.5l-0.156-5.469"/>
\t<path id="WI_Great_Lakes" fill="none" stroke="#000000" stroke-width="2" d="M590.937,259.531l-0.624,1.25l-1.093-0.156
\t\tl-0.626-1.094l-2.655-0.781l-1.093,0.156l-1.719,0.938l-0.937-0.625l0.624-1.875l1.877-2.969l1.094-1.094l-1.876-1.406
\t\tl-2.032,0.781l-2.811,1.875l-7.189,3.125l-2.812,0.625l-2.812-0.469l-0.782-0.937 M636.25,343.438l-0.157-4.062L634.531,335
\t\tl-0.624-5.937l-1.095-2.344l0.934-2.969l0.785-2.812l1.406-2.5l-0.624-3.281l-0.626-3.438l0.471-1.719l1.878-2.344L637.19,305
\t\tl-0.782-1.25l0.626-2.5l0.469-3.125l2.656-5.469l2.81-6.563l0.157-2.188l-0.313-0.937l-0.78,0.469l-4.062,6.094l-2.655,3.906
\t\tl-1.876,1.719l-0.784,2.188l-1.406,0.781L630.155,300l-1.406-0.313l-0.156-1.719l1.249-2.344l2.03-4.531l1.719-1.562l1.093-2.5"/>
\t<path id="MN_Great_Lakes" fill="none" stroke="#000000" stroke-width="2" d="M565.937,257.344l-0.624-0.781l3.284-2.969
\t\tl1.247-0.156l4.377-4.844l1.717-0.781l2.19-3.75l2.34-3.438l2.972-2.5l4.061-1.719l7.501-3.594l2.815-0.781
\t\tc0,0,2.968-1.719,3.281-2.344c0.313-0.625,0.624-1.406,0.624-1.406"/>
</g>
<path id="path5767" fill="none" stroke="#F89A83" stroke-width="0.3956" d="M774.203,261.996c0.934,0.892,1.465,1.605,1.465,1.605
\tl0.578,1.16l0.133-0.134"/>
</svg>
EOF;
$im = new Imagick();
$im->readImageBlob($image);
$im->setImageFormat("jpeg");
$im->scaleImage(600, 150, true);
$im->setCompression(Imagick::COMPRESSION_JPEG);
$im->setCompressionQuality(80);
$output = $im->getimageblob();
$outputtype = $im->getFormat();
header("Content-type: {$outputtype}");
Header("Cache-Control: max-age=3600, s-maxage=3600, public, must-revalidate");
echo $output;
exit;
示例13: getImageAction
/**
* @Route("/{id}/image/{image_id}", name="gallery_image")
*
* @ParamConverter("gallery", class="OesteveGrupetaBundle:Gallery", options={"mapping" ={"id" = "id"}})
* @ParamConverter("image", class="OesteveGrupetaBundle:Image", options={"mapping" ={"image_id" = "id"}})
*
* @Method("GET")
*/
public function getImageAction(Gallery $gallery, Image $image, Request $request)
{
$width = $request->query->get("width");
$fileContent = base64_decode($image->getContent());
if ($width != null) {
$tmpDir = $this->container->getParameter('tmp_dir');
$cachedDirName = $tmpDir . '/activities/';
$cachedFileName = $cachedDirName . '/img_' . $width . '_' . $image->getId();
if (!file_exists($cachedDirName)) {
mkdir($cachedDirName, 0777, TRUE);
}
if (file_exists($cachedFileName)) {
$fileContent = file_get_contents($cachedFileName);
} else {
$img = new \Imagick();
$img->readimageblob($fileContent);
//Hacer una miniatura de una imagen cargada. 0 para los ejes preserva la proporción de aspecto
$img->thumbnailImage($width, 0);
$fileContent = $img->getimageblob();
if ($tmpDir != null) {
file_put_contents($cachedFileName, $fileContent);
}
}
}
$f = finfo_open();
$mime_type = finfo_buffer($f, $fileContent, FILEINFO_MIME_TYPE);
$response = new Response();
$response->headers->set('Content-Type', $mime_type);
$response->headers->set('Expires', 0);
$response->headers->set('Cache-Control', 'must-revalidate');
$response->headers->set('Pragma', 'public');
$response->headers->set('Content-length', strlen($fileContent));
$response->setContent($fileContent);
return $response;
}
示例14: imageProcessImageMagick
private function imageProcessImageMagick()
{
$this->source_image_w = $this->image_info[0];
$this->source_image_h = $this->image_info[1];
$this->source_image_x = 0;
$this->source_image_y = 0;
$dst_x = 0;
$dst_y = 0;
if ($this->clipping != IMAGE_CORE_CM_DEFAULT) {
// clipping method 1: left or top 2: middle 3: right or bottom
$this->source_image_w -= $this->start_x;
$this->source_image_h -= $this->start_y;
if ($this->source_image_w * $this->height > $this->source_image_h * $this->width) {
$match_w = round($this->width * $this->source_image_h / $this->height);
$match_h = $this->source_image_h;
} else {
$match_h = round($this->height * $this->source_image_w / $this->width);
$match_w = $this->source_image_w;
}
switch ($this->clipping) {
case IMAGE_CORE_CM_LEFT_OR_TOP:
$this->source_image_x = 0;
$this->source_image_y = 0;
break;
case IMAGE_CORE_CM_MIDDLE:
$this->source_image_x = round(($this->source_image_w - $match_w) / 2);
$this->source_image_y = round(($this->source_image_h - $match_h) / 2);
break;
case IMAGE_CORE_CM_RIGHT_OR_BOTTOM:
$this->source_image_x = $this->source_image_w - $match_w;
$this->source_image_y = $this->source_image_h - $match_h;
break;
}
$this->source_image_w = $match_w;
$this->source_image_h = $match_h;
$this->source_image_x += $this->start_x;
$this->source_image_y += $this->start_y;
}
$resize_height = $this->height;
$resize_width = $this->width;
if ($this->scale != IMAGE_CORE_SC_NOT_KEEP_SCALE) {
if ($this->scale == IMAGE_CORE_SC_BEST_RESIZE_WIDTH) {
$resize_height = round($this->width * $this->source_image_h / $this->source_image_w);
$resize_width = $this->width;
} else {
if ($this->scale == IMAGE_CORE_SC_BEST_RESIZE_HEIGHT) {
$resize_width = round($this->height * $this->source_image_w / $this->source_image_h);
$resize_height = $this->height;
}
}
}
$im = new Imagick();
$im->readimageblob(file_get_contents($this->source_image));
$im->setCompressionQuality($this->quality);
if ($this->source_image_x or $this->source_image_y) {
$im->cropImage($this->source_image_w, $this->source_image_h, $this->source_image_x, $this->source_image_y);
}
$im->thumbnailImage($resize_width, $resize_height, true);
if ($this->option == IMAGE_CORE_OP_TO_FILE and $this->new_image) {
file_put_contents($this->new_image, $im->getimageblob());
} else {
if ($this->option == IMAGE_CORE_OP_OUTPUT) {
$output = $im->getimageblob();
$outputtype = $im->getFormat();
header("Content-type: {$outputtype}");
echo $output;
die;
}
}
return TRUE;
}
示例15: mkdir
mkdir($cache_dir, 0777, true);
}
$cache_file = sprintf("%s/%s.png", $cache_dir, substr($hash, 3));
if (file_exists($cache_file)) {
header('Content-type: image/png');
$fp = fopen($cache_file, 'r');
fpassthru($fp);
die;
}
// Never Expire
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Read the background image into memory
$imagick = new Imagick();
$imagick->readImage(dirname(__FILE__) . '/achievement.gif');
// Setup our annotation settings
$draw = new ImagickDraw();
$draw->setFillColor('white');
$draw->setFont('./ConvectionRegular.ttf');
$draw->setFontSize(20);
// Annotate the user input
$imagick->annotateImage($draw, 75, 55, 0, $requested_text);
// Annotate the header
$draw->setFontSize(25);
$imagick->annotateImage($draw, 75, 30, 0, "ACHIEVEMENT UNLOCKED");
// Output the image
$imagick->setImageFormat('png');
header('Content-type: image/png');
file_put_contents($cache_file, $imagick->getimageblob());
$fp = fopen($cache_file, 'r');
fpassthru($fp);