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

Imagick::contrastImage

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

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

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

imagick.contrastimage.php

Imagick::contrastImage

(PECL imagick 2, PECL imagick 3)

Imagick::contrastImageChange the contrast of the image

= NULL

public Imagick::contrastImage(bool $sharpen): bool

Enhances the intensity differences between the lighter and darker elements of the image. Set sharpen to a value other than 0 to increase the image contrast otherwise the contrast is reduced.

Параметри

sharpen

The sharpen value

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

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

Errors/Exceptions

Throws ImagickException on error.

Примери

Пример #1 Imagick::contrastImage()

<?php
function contrastImage($imagePath, $contrastType) {
$imagick = new \Imagick(realpath($imagePath));
if (
$contrastType != 2) {
$imagick->contrastImage($contrastType);
}

header("Content-Type: image/jpg");
echo
$imagick->getImageBlob();
}

?>

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

removespam dot roland at tannerritchie dot com
пред 11 години
Both xyking and quickshiftin include errors in their comments. xyking's error is in looping through negative numbers. quickshifting is incorrect in stating that 0 *increases* contrast (it does not - it decreases it).

Here is a (tested, working) method to increment or decrement contrast:
<?php
class Images {
public function contrastImage($contrast, $imagePath){

$this->image = new Imagick();
$this->image->readImage($imagePath);                     

 if ($contrast > 0){
                for ($i = 1; $i < $contrast; $i++){
                    $this->image->contrastImage(1);
                }
            }else if ($contrast <= 0) {

                for ($i = 0; $i > $contrast; $i--) {

                    $this->image->contrastImage(0);
                }
            }
     }
}
?>
xyking
пред 15 години
Tip: 
<?php
$image->contrastImage(1); //Increase contrast once
$image->contrastImage(1); //Increase contrast more
$image->contrastImage(1); //Increase contrast even more

$image->contrastImage(0); //Decrease contrast once
$image->contrastImage(0); //Decrease contrast more
$image->contrastImage(0); //Decrease contrast even more

//This could be made into a function like this:
public function contrast($level) {
        $level = (int)$level;
        if ($level < -10) {
            $level = -10;
        } else if ($level > 10) {
            $level = 10;
        }
        if ($level > 0) {
            for ($i = 0; $i < $level; $i++) {
                $this->image->contrastImage(1);
            }
        } else if ($level < 0) {
            for ($i = $level; $i > 0; $i--) {
                $this->image->contrastImage(0);
            }
        }
    }
?>
quickshiftin at gmail dot com
пред 11 години
xyking's comment is wrong so be careful if you read it. You pass a value of 0 to *increase* the contrast.
Навигација

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

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

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

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

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

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

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