PHP Doku:: Scales the size of an image - function.imagick-scaleimage.html

Verlauf / Chronik / History: (2) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzBildverarbeitung und -generierungImage Processing (ImageMagick)The Imagick classImagick::scaleImage

Ein Service von Reinhard Neidl - Webprogrammierung.

The Imagick class

<<Imagick::sampleImage

Imagick::segmentImage>>

Imagick::scaleImage

(PECL imagick 2.0.0)

Imagick::scaleImageScales the size of an image

Beschreibung

bool Imagick::scaleImage ( int $cols , int $rows [, bool $bestfit = false ] )
Warnung

Diese Funktion ist bis jetzt nicht dokumentiert. Es steht nur die Liste der Argumente zur Verfügung.

Scales the size of an image to the given dimensions. The other parameter will be calculated if 0 is passed as either param.

Hinweis: Das Verhalten des Parameters bestfit hat sich mit Imagick 3.0.0 geändert. Vor dieser Version wurde ein Bild der Größe 200x150 bei der angegebenen Größe von 400x400 nicht verändert. In Imagick 3.0.0 und späteren Versionen wird dieses Bild auf die Größe 400x300 hochgerechnet, da dies die passendste größe für die angegebene Bildgröße ist. Wenn der bestfit-Parameter angegeben wird, so muss sowohl eine Breite als auch eine Höhe angegeben werden.

Parameter-Liste

cols

rows

bestfit

Rückgabewerte

Liefert TRUE bei Erfolg.

Fehler/Exceptions

Wirft ImagickException bei Fehlern.

Changelog

Version Beschreibung
2.1.0 Added optional fit parameter. This method now supports proportional scaling. Pass zero as either parameter for proportional scaling.


4 BenutzerBeiträge:
- Beiträge aktualisieren...
peter at icb dot at
22.09.2009 14:25
If using the fit-parameter this function sometimes seems not to work when one of the two sizes (width or height) is the same size as the image has. For example:

<?php
$image
= new Imagick('800x480.jpg');
$image->scaleImage(640, 480, true);

// $image is still 800x480
?>

You have to calculate the new sizes yourself and use false for $fit in this case.
octave at web dot de
23.07.2009 11:57
When using the "fit = true" option, the image will only scale down, but never scale up:

<?php
$im
= new Imagick('1600x1200.jpg');

$im->scaleImage(2000, 1500, true); // => 1600x1200

$im->scaleImage(1000, 500, true); // => 666x500
?>
benford at bluhelix dot com
16.06.2009 17:38
If anyone finds "The other parameter will be calculated if 0 is passed as either param. " to be a bit confusing, it means approximately this:

<?php
$im
= new Imagick('example.jpg');
$im->scaleImage(300, 0);
?>

This scales the image such that it is now 300 pixels wide, and automatically calculates the height to keep the image at the same aspect ratio.

<?php
$im
= new Imagick('example.jpg');
$im->scaleImage(0, 300);
?>

Similarly, this example scales the image to make it 300 pixels tall, and the method automatically recalculates the image's height to maintain the aspect ratio.
vincent dot hoen at gmail dot com
2.08.2007 15:37
Here is an easy way to resize an animated gif :

$picture = new Imagick('animated_gif.gif');

foreach($picture as $frame){
    $frame->scaleImage($width, $height);
}



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)