Imagick::thumbnailImage


wizard apg

CHANGES the size of an image.



<?php

bool 
public Imagick::thumbnailImage(
       
int $columns,
       
int $rows,
    
bool $bestfit false,
    
bool $fill false,
    
bool $legacy false
);

?>

$columns


As Image width.



$rows


As Image height.



$bestfit


To force maximum values.

If true then columns and rows parameters are used as maximums for each side.
Both sides will be scaled down until they match or are smaller than the parameter given for the side.
If is used both width and height must be given.



$legacy


true or false.



$fill


true or false.





This function returns a TRUE on success.

Changes the size of an image to the given dimensions and removes any associated profiles.

The goal is to produce small, low cost thumbnail images suited for display on the Web.

Before Imagick 3.0.0 given dimensions 400x400 an image of dimensions 200x150 would be left untouched.

In Imagick 3.0.0 and later the image would be scaled up to size 400x300 as this is the "best fit" for the given dimensions.



  1 EXERCISE   

<?php

$img1 
= new imagick(PATH2IMGW '/jpg/aa.jpg');
$str1img 'img/results/aath491.jpg';

$img1->thumbnailImage(100100truetrue);
$str1 $img1->getImageBlob();

$img imagecreatefromstring($str1);

imagejpeg($img$str1img);

echo 
basename($str1img); ?>
<br><br>
<img src="<?php echo $str1img?>"
 alt="<?php echo $str1img?>
 title="<?php echo $str1img?>">

 RESULT   

aath491.jpg

img/results/aath491.jpg apr

  2 EXERCISE   

<?php

$img2 
= new imagick(PATH2IMGW '/png/wizard.png');
$str2img 'img/results/wizard492.png';

$img2->thumbnailImage(100100truetrue);
$str2 $img2->getImageBlob();

$img imagecreatefromstring($str2);

imagepng($img$str2img);

echo 
basename($str2img); ?>
<br><br>
<img src="<?php echo $str2img?>"
 alt="<?php echo $str2img?>
 title="<?php echo $str2img?>">

wizard492.png

img/results/wizard492.png apr

  3 EXERCISE   

<?php

$img3 
= new imagick(PATH2IMGW '/gif/E 01 01.gif');
$str3img 'img/gif/E 01 01t493.gif';

// Run this exercise several times

$c1 mt_rand(0255);
$c2 mt_rand(0255);
$c3 mt_rand(0255);

echo 
"rgb($c1$c2$c3)<br><br>";
 
$img3->setImageBackgroundColor("rgb($c1$c2$c3)");

$img3->thumbnailImage(300300false);
$str3 $img3->getImageBlob();

$img imagecreatefromstring($str3);

imagegif($img$str3img);

echo 
basename($str3img); ?>
<br><br>
<img src="<?php echo $str3img?>"
 alt="<?php echo $str3img?>
 title="<?php echo $str3img?>">

  4 EXERCISE   

<?php

$img4 
= new imagick(PATH2IMGW '/gif/E 01 01.gif');
$str4img 'img/results/E 01 01t494.gif';

// Run this exercise several times

$c1 mt_rand(0255);
$c2 mt_rand(0255);
$c3 mt_rand(0255);

echo 
"rgb($c1$c2$c3)<br><br>";
 
$img4->setImageBackgroundColor("rgb($c1$c2$c3)");

$img4->thumbnailImage(300300true);
$str4 $img4->getImageBlob();

$img imagecreatefromstring($str4);

imagegif($img$str4img);

echo 
basename($str4img); ?>
<br><br>
<img src="<?php echo $str4img?>"
 alt="<?php echo $str4img?>
 title="<?php echo $str4img?>">

$imagick->setImageBackgroundColor("rgb(152, 54, 24)")

$imagick->thumbnailImage( 300, 300, true, false )

E 01 01t495.gif

img/results/E 01 01t495.gif apr