PHP 8.3.4 Released!

Imagick::appendImages

(PECL imagick 2, PECL imagick 3)

Imagick::appendImages画像群を追加する

説明

public Imagick::appendImages(bool $stack): Imagick

画像群を、ひとつの大きな画像に追加します。

パラメータ

stack

画像を垂直方向に積むかどうか。デフォルト (あるいは false を指定した場合) は、画像を左から右に積みます。stacktrue の場合は、画像を上から下に積みます。

戻り値

成功した場合に Imagick インスタンスを返します。

エラー / 例外

エラー時に ImagickException をスローします。

例1 Imagick::appendImages() の例

<?php

/* 新しい imagick オブジェクトを作成します */
$im = new Imagick();

/* 赤、緑、そして青の画像を作成します */
$im->newImage(100, 50, "red");
$im->newImage(100, 50, "green");
$im->newImage(100, 50, "blue");

/* それらをひとつの画像に追加します */
$im->resetIterator();
$combined = $im->appendImages(true);

/* 画像を出力します */
$combined->setImageFormat("png");
header("Content-Type: image/png");
echo
$combined;
?>

上の例の出力は、 たとえば以下のようになります。

出力例 : Imagick::appendImages()

add a note

User Contributed Notes 3 notes

up
13
Brandon
14 years ago
# How to combine a multi-page pdf file into a single long image:

<?php
$im1
= new Imagick();
$im1->readImage('multi-page-pdf.pdf');
$im1->resetIterator();
# Combine multiple images into one, stacked vertically.
$ima = $im1->appendImages(true);
$ima->setImageFormat("png");
header("Content-Type: image/png");
echo
$ima;
?>
up
0
adao at adao dot eti dot br
9 years ago
# change $ima to $ima->getimagesblob()

<?php
$im1
= new Imagick();
$im1->readImage('multi-page-pdf.pdf');
$im1->resetIterator();
# Combine multiple images into one, stacked vertically.
$ima = $im1->appendImages(true);
$ima->setImageFormat("png");
header("Content-Type: image/png");
echo
$ima->getimagesblob();
?>
up
-2
Anonymous
10 years ago
Sometimes when running this code on a long running apache24 instance on a server with minimal memory the final "echo $ima;" returns an empty string.

Doing an "apache graceful" seems to clear this up. There appears to be no other way to correct OR DETECT this problem. Suckky.
To Top