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

Imagick::setOption

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

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

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

imagick.setoption.php

Imagick::setOption

(PECL imagick 2, PECL imagick 3)

Imagick::setOptionSet an option

= NULL

public Imagick::setOption(string $key, string $value): bool

Associates one or more options with the wand.

Параметри

key

value

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

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

Примери

Example #1 Attempt to reach '$extent' sizeImagick::setOption()

<?php
function renderJPG($extent) {
$imagePath = $this->control->getImagePath();
$imagick = new \Imagick(realpath($imagePath));
$imagick->setImageFormat('jpg');
$imagick->setOption('jpeg:extent', $extent);
header("Content-Type: image/jpg");
echo
$imagick->getImageBlob();
}

?>

Пример #2 Imagick::setOption()

<?php
function renderPNG($imagePath, $format) {

$imagick = new \Imagick(realpath($imagePath));
$imagick->setImageFormat('png');
$imagick->setOption('png:format', $format);
header("Content-Type: image/png");
echo
$imagick->getImageBlob();
}

//Save as 64bit PNG.
renderPNG($imagePath, 'png64');

?>

Пример #3 Imagick::setOption()

<?php
function renderCustomBitDepthPNG() {
$imagePath = $this->control->getImagePath();
$imagick = new \Imagick(realpath($imagePath));
$imagick->setImageFormat('png');

$imagick->setOption('png:bit-depth', '16');
$imagick->setOption('png:color-type', 6);
header("Content-Type: image/png");
$crash = true;
if (
$crash) {
echo
$imagick->getImageBlob();
}
else {
$tempFilename = tempnam('./', 'imagick');
$imagick->writeimage(realpath($tempFilename));
echo
file_get_contents($tempFilename);
}
}

?>

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

kicha at kreker dot org
пред 10 години
List of options (with key => value) on official imagemagick site:
http://www.imagemagick.org/script/command-line-options.php#define
alexandre at gaigalas dot net
пред 14 години
If you want to extract a preview from a PDF file using the CropBox instead of the whole document, setOption() is the right method:

<?php
$handler = new Imagick();
$handler->setOption('pdf:use-cropbox', 'true');
$handler->readImage($imageFileName);
$handler->thumbnailImage(200, 200, true);
$handler->setImageFormat('jpeg');
$handler->writeImage($destThumbFileName);
?>

It is the equivalent to the -define pdf:use-cropbox=true for the convert command line tool. pdf:use-trimbox is also available.

Note that on my environment the setOption only worked when i called it before the readImage method, which means that you can't pass the filename to the Imagick constructor directly.
SkepticaLee
пред 5 години
Actually setImageArtifact () can be used if setOption () fails, e.g.

$im->setImageartifact ("distort:viewport", "960x540+0-151");

Or maybe setOption () is deprecated.
dodginess на yahoo dot com
пред 1 година
It does not appear to be possible to disable anti-aliasing using the setOption() method as might be expected, and calling the setOption() method like this does not do anything:

$imagick->setOption('antialias', FALSE);

As discussed at https://github.com/Imagick/imagick/issues/83 the correct way to do this appears to be to use the setAntiAlias() method, which is not currently documented in the PHP manual. As an example, to disable anti-aliasing for an image you can do this:

$imagick->setAntiAlias(FALSE);
Навигација

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

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

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

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

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

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

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