// 初始化画布
    $bg_file = Yii::getAlias('@frontend/web/test/wxbg.jpg');
    $image = new \Imagick($bg_file);

    // 写字
    $font_file = Yii::getAlias('@frontend/web/test/msyhbd.ttc');
    $draw = new \ImagickDraw();
    $metrics = $image->queryFontMetrics($draw, $name);
    $draw->annotation(158, 50 + $metrics['ascender'], $name);

    // 二维码
    $qr_image = new \Imagick(Yii::getAlias('@frontend/web/test/qr.png'));
    $qr_image->scaleImage(248, 248);
    $image->compositeImage($qr_image, \Imagick::COMPOSITE_COPY, 254, 504);

    // 返回
    $response = Yii::$app->getResponse();
    $response->format = Response::FORMAT_RAW;
    $response->headers->set('Content-Type', 'image/jpeg');
    $response->data = $image->getImageBlob();
    return $response->send();


您的电子邮箱地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see