当前位置: 首页>>代码示例>>PHP>>正文


PHP ImagickDraw::setStrokeAntiAlias方法代码示例

本文整理汇总了PHP中ImagickDraw::setStrokeAntiAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::setStrokeAntiAlias方法的具体用法?PHP ImagickDraw::setStrokeAntiAlias怎么用?PHP ImagickDraw::setStrokeAntiAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImagickDraw的用法示例。


在下文中一共展示了ImagickDraw::setStrokeAntiAlias方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: analyzeImage

 /**
  * @param \Imagick $imagick
  * @param int $graphWidth
  * @param int $graphHeight
  */
 public static function analyzeImage(\Imagick $imagick, $graphWidth = 255, $graphHeight = 127)
 {
     $sampleHeight = 20;
     $border = 2;
     $imagick->transposeImage();
     $imagick->scaleImage($graphWidth, $sampleHeight);
     $imageIterator = new \ImagickPixelIterator($imagick);
     $luminosityArray = [];
     foreach ($imageIterator as $row => $pixels) {
         /* Loop through pixel rows */
         foreach ($pixels as $column => $pixel) {
             /* Loop through the pixels in the row (columns) */
             /** @var $pixel \ImagickPixel */
             if (false) {
                 $color = $pixel->getColor();
                 $luminosityArray[] = $color['r'];
             } else {
                 $hsl = $pixel->getHSL();
                 $luminosityArray[] = $hsl['luminosity'];
             }
         }
         /* Sync the iterator, this is important to do on each iteration */
         $imageIterator->syncIterator();
         break;
     }
     $draw = new \ImagickDraw();
     $strokeColor = new \ImagickPixel('red');
     $fillColor = new \ImagickPixel('red');
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     $draw->setStrokeWidth(0);
     $draw->setFontSize(72);
     $draw->setStrokeAntiAlias(true);
     $previous = false;
     $x = 0;
     foreach ($luminosityArray as $luminosity) {
         $pos = $graphHeight - 1 - $luminosity * ($graphHeight - 1);
         if ($previous !== false) {
             /** @var $previous int */
             //printf ( "%d, %d, %d, %d <br/>\n" , $x - 1, $previous, $x, $pos);
             $draw->line($x - 1, $previous, $x, $pos);
         }
         $x += 1;
         $previous = $pos;
     }
     $plot = new \Imagick();
     $plot->newImage($graphWidth, $graphHeight, 'white');
     $plot->drawImage($draw);
     $outputImage = new \Imagick();
     $outputImage->newImage($graphWidth, $graphHeight + $sampleHeight, 'white');
     $outputImage->compositeimage($plot, \Imagick::COMPOSITE_ATOP, 0, 0);
     $outputImage->compositeimage($imagick, \Imagick::COMPOSITE_ATOP, 0, $graphHeight);
     $outputImage->borderimage('black', $border, $border);
     $outputImage->setImageFormat("png");
     App::cachingHeader("Content-Type: image/png");
     echo $outputImage;
 }
开发者ID:danack,项目名称:imagick-demos,代码行数:62,代码来源:Image.php

示例2: fxAnalyzeImage

function fxAnalyzeImage(\Imagick $imagick)
{
    $graphWidth = $imagick->getImageWidth();
    $sampleHeight = 20;
    $graphHeight = 128;
    $border = 2;
    $imageIterator = new \ImagickPixelIterator($imagick);
    $reds = [];
    foreach ($imageIterator as $pixels) {
        /* Loop through pixel rows */
        foreach ($pixels as $pixel) {
            /* Loop through the pixels in the row (columns) */
            /** @var $pixel \ImagickPixel */
            $color = $pixel->getColor();
            $reds[] = $color['r'];
        }
        $imageIterator->syncIterator();
        /* Sync the iterator, this is important to do on each iteration */
    }
    $draw = new \ImagickDraw();
    $strokeColor = new \ImagickPixel('red');
    $fillColor = new \ImagickPixel('none');
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(1);
    $draw->setFontSize(72);
    $draw->setStrokeAntiAlias(true);
    $x = 0;
    $points = [];
    foreach ($reds as $red) {
        $pos = $graphHeight - $red * $graphHeight / 256;
        $points[] = ['x' => $x, 'y' => $pos];
        $x += 1;
    }
    $draw->polyline($points);
    $plot = new \Imagick();
    $plot->newImage($graphWidth, $graphHeight, 'white');
    $plot->drawImage($draw);
    $outputImage = new \Imagick();
    $outputImage->newImage($graphWidth, $graphHeight + $sampleHeight, 'white');
    $outputImage->compositeimage($plot, \Imagick::COMPOSITE_ATOP, 0, 0);
    $imagick->resizeimage($imagick->getImageWidth(), $sampleHeight, \Imagick::FILTER_LANCZOS, 1);
    $outputImage->compositeimage($imagick, \Imagick::COMPOSITE_ATOP, 0, $graphHeight);
    $outputImage->borderimage('black', $border, $border);
    $outputImage->setImageFormat("png");
    header("Content-Type: image/png");
    echo $outputImage;
}
开发者ID:biswajit-paul,项目名称:gittest,代码行数:48,代码来源:functions.php


注:本文中的ImagickDraw::setStrokeAntiAlias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。