PHP.mk документација

Imagick::compositeImage

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

imagick.compositeimage.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека imagick.compositeimage.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Imagick::compositeImage

Референца за `imagick.compositeimage.php` со подобрена типографија и навигација.

imagick.compositeimage.php

Imagick::compositeImage

(PECL imagick 2, PECL imagick 3)

Imagick::compositeImageКомпозирај една слика врз друга

= NULL

public function Imagick::compositeImage(
         (PECL imagick 2, PECL imagick 3) $composite_object,
         int $composite,
         int $x,
         int $y,
         int $channel од Imagick 3.4.4. Силно се обесхрабрува потпирањето на оваа функција.
): bool

Композирај една слика врз друга на наведената позиција. Сите дополнителни аргументи потребни за алгоритмот за композирање треба да се предадат на setImageArtifact со 'compose:args' како прв параметар и податоците како втор параметар.

Параметри

composite_object

Композирај една слика врз друга на наведената позиција. Сите дополнителни аргументи потребни за алгоритмот за композирање треба да се поминат на setImageArtifact со 'compose:args' како прв параметар и податоците како втор параметар.

compose

Imagick објект кој го држи композитната слика Константи за оператор за композиција

x

Оператор за композирање. Погледнете

y

Вертикалното поместување на композитната слика

channel

Белата точка на сликата. Обезбедете каква било константа на каналот што е валидна за вашиот режим на канал. За да се примени на повеќе од еден канал, комбинирајте ги константите на типот на каналот користејќи бинарни оператори. Погледнете ја оваа листа на.

Вратени вредности

Патеката до PHP скриптата што треба да се провери. true на успешен исход.

Примери

Пример #1 Користење Хоризонталното поместување на композитната слика:

Imagick::compositeImage()

<?php

// Equivalent to running the command
// convert src1.png src2.png -compose mathematics -define compose:args="1,0,-0.5,0.5" -composite output.png

$src1 = new \Imagick("./src1.png");
$src2 = new \Imagick("./src2.png");

$src1->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$src1->setImageArtifact('compose:args', "1,0,-0.5,0.5");
$src1->compositeImage($src2, Imagick::COMPOSITE_MATHEMATICS, 0, 0);
$src1->writeImage("./output.png");

?>

Види Исто така

Белешки од корисници 4 белешки

Imagick::setImageArtifact()
пред 18 години
Here is an example on how to compose two images into a single one. The Imagick class utilises the exception handling model introduced in PHP5 and thus we will do that as well. Let's presume, that we have a directory in our filesystem, which contains our program and the two images we want to operate on.

<?php
try
{
    // Let's check whether we can perform the magick.
    if (TRUE !== extension_loaded('imagick'))
    {
        throw new Exception('Imagick extension is not loaded.');
    }

    // This check is an alternative to the previous one.
    // Use the one that suits you better.
    if (TRUE !== class_exists('Imagick'))
    {
        throw new Exception('Imagick class does not exist.');
    }

    // Let's find out where we are.
    $dir = dirname(__FILE__);

    // Let's read the images.
    $glasses = new Imagick();
    if (FALSE === $glasses->readImage($dir . '/glasses.png'))
    {
        throw new Exception();
    }

    $face = new Imagick();
    if (FALSE === $face->readImage($dir . '/face.jpg'))
    {
        throw new Exception();
    }

    // Let's put the glasses on (10 pixels from left, 20 pixels from top of face).
    $face->compositeImage($glasses, Imagick::COMPOSITE_DEFAULT, 10, 20);

    // Let's merge all layers (it is not mandatory).
    $face->flattenImages();

    // We do not want to overwrite face.jpg.
    $face->setImageFileName($dir . '/face_and_glasses.jpg');

    // Let's write the image.
    if  (FALSE == $face->writeImage())
    {
        throw new Exception();
    }
}

catch (Exception $e)
{
    echo 'Caught exception: ' . $e->getMessage() . "\n";
}

exit(0);
?>
Also a couple more words on the Imagick::COMPOSITE_DEFAULT argument. The images we are composing together are separate layers. Not only can we put them in specific order, but we can also choose the way we want them to interfere with each other. And here comes the second argument of the compositeImage method. It can be given either as a constant or as the integer value of that constant. You can use the reflection API of PHP5 to get the list of them.

<?php
Reflection::export(new ReflectionClass('Imagick'));
?>

Just look for COMPOSITE_* constants in the "Constants" section.
m dot roszka at textend dot net
пред 5 години
There has been changes to Imagick constants in new version. Please read new list of constants like this.

<?php

$img = new \Imagick();
$reflection_class = new ReflectionClass($img);

die(var_dump($reflection_class->getConstants()));

?>
Imagick::getImageHistogram()
пред 14 години
To copy the alpha channel from one image to another, you can do the following:

<?php

$img1 = new Imagick( "image1.png" );
$img2 = new Imagick( "image2.png" );

$img1->compositeImage( $img2, imagick::COMPOSITE_COPYOPACITY, 0, 0 );

header('Content-type: image/png');
echo $img1;

?>
elizapinchley at google dot com
пред 16 години
You might need to set the colorspace the same when composing two images over each other

<?php
//Creating two Imagick object
$first = new Imagick('first.jpg');
$second = new Imagick('second.jpg');

// Set the colorspace to the same value
$first->setImageColorspace($second->getImageColorspace() );

//Second image is put on top of the first
$first->compositeImage($second, $second->getImageCompose(), 5, 5);

//new image is saved as final.jpg
$first->writeImage('final.jpg');
?>
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.