• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • Imagick::textureImage()

    (PECL imagick 2.0.0)

    Repeatedly tiles the texture image

    说明

    Imagick::textureImage(Imagick$texture_wand): Imagick

    Repeatedly tiles the texture image across and down the image canvas.

    参数

    $texture_wand

    Imagick object to use as texture image

    返回值

    Returns a new Imagick object that has the repeated texture applied.

    错误/异常

    错误时抛出 ImagickException。

    范例

    Example #1 Imagick::textureImage()

    <?php
    function textureImage($imagePath) {
        $image = new \Imagick();
        $image->newImage(640, 480, new \ImagickPixel('pink'));
        $image->setImageFormat("jpg");
        $texture = new \Imagick(realpath($imagePath));
        $texture->scaleimage($image->getimagewidth() / 4, $image->getimageheight() / 4);
        $image = $image->textureImage($texture);
        header("Content-Type: image/jpg");
        echo $image;
    }
    ?>
    
    This method doesn't actually return TRUE on success, it returns an Imagick with the texture applied, but the original Imagick object is not modified. As per the other examples on here, you need to use the result of textureImage call as your new tiled image.
    <?php
    $image = new Imagick();
    $image->newImage(500, 500, new ImagickPixel('red'));
    $image->setImageFormat("png");
    $type=$image->getFormat();
    header("Content-type: $type");
    $texture = new Imagick();
    $texture->readImage('texture.png');
    $image = $image->textureImage($texture);
    echo $image;
    ?>
    This works for me, however, I give no guarantees that the above example is the proper usage of this function.