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

Imagick::setImageFormat

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

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

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

imagick.setimageformat.php

Imagick::setImageFormat

(PECL imagick 2, PECL imagick 3)

Imagick::setImageFormatЈа поставува формата на одредена слика

= NULL

public Imagick::setImageFormat(string $format): bool

Ја поставува формата на одредена слика во низа.

Параметри

format

String presentation of the image format. Format support depends on the ImageMagick installation.

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

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

Белешки од корисници Управување со PDO конекции

nathan at crause dot name
пред 15 години
For those of you completely confused by the utter lack of documentation for this class (including notes being dropped, probably this one included), the differences between any "setXXX" and "setImageXXX" seems to be entirely dependently on HOW the image was loaded.

If the image was loaded at object constructor time, it seems that you use "setXXX" - if you loaded it after the fact (such as via "readImageBlob") then you use "setImageXXX".

This is irregular, however. For example:

<?php
        $image = new Imagick();

        $image->setResolution(300, 300);
        $image->readImageBlob(...);
        // convert the output to JPEG
        $image->setImageFormat('jpeg');
        $image->setImageCompressionQuality(90);
?>

Note that we use "setResolution" not "setImageResolution".
optymizer at yahoo dot com
пред 18 години
The previous example did not work for me. I received an error that the IMagick object cannot be converted to string.

This example uses the IMagick::getImageBlob() method to properly output the contents of the converted image:

function getImage($filename)
{
            $image->readImage($filename);
            $image->setImageFormat("png");
            header("Content-type: image/png");
            echo $image->getImageBlob();
}

Hope this helps!
layzee dot dk at gmail dot com
12 години пред
This method only affects the individual loaded/constructed images.

To set the format of the entire object, use the Imagick::setFormat method. E.g. load TIFF files, then use setFormat('pdf') on the Imagick object, then writeImagesFile('foo.pdf') or getImagesBlob().
маркус.с.шмитц@gmail.com
пред 13 години
If you use writeFile or writeFiles without setting the format, it is automatically set according to the file extension used within the parameter of writeFile.
andy at live dot nl
пред 17 години
I had a problem when using $im->setImageFormat('jpeg');
Image colors got inverted when i converted pdfs to jpg thumbs.
Had to add $im->setImageColorspace(255); to solve it.

<?php
// read page 1
$im = new imagick( 'test.pdf[ 0]' );

// convert to jpg
$im->setImageColorspace(255);
$im->setCompression(Imagick::COMPRESSION_JPEG);
$im->setCompressionQuality(60);
$im->setImageFormat('jpeg');

//resize
$im->resizeImage(290, 375, imagick::FILTER_LANCZOS, 1);  

//write image on server
$im->writeImage('thumb.jpg');
$im->clear();
$im->destroy();
?>
Devo
пред 18 години
A list of formats can be found here: http://www.imagemagick.org/script/formats.php

Formats marked with a W can be output to file with writeImage (capabilities depend on your particular installation of course).

For example:

<?php
// create new imagick object from image.jpg
$im = new Imagick( "image.jpg" );

// change format to png
$im->setImageFormat( "png" );

// output the image to the browser as a png
header( "Content-Type: image/png" );
echo $im;

// or you could output the image to a file:
//$im->writeImage( "image.png" );
?>
barclay[dot]loftus[at]gmail.com
пред 18 години
Another note about image output. For jpeg images, the quality is adjusted by Imagick::setCompressionQuality(). 

<?php
$img->setCompressionQuality(90);
$img->setImageFormat('jpeg');
header('Content-type: image/jpg');
echo $img;
?>
Навигација

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

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

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

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

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

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

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