Imagick::adaptiveResizeImage


wizard apg

ADAPTATIVELY resize one image with data dependent triangulation.



<?php

bool 
public Imagick::adaptiveResizeImage(
                                     
int $columns,
                                     
int $rows,
                                  
bool $bestfit = false,
                                  
bool $legacy = false
                                               
);

?>

$columns


This is a number of columns in the scaled image.



$rows


This is a number of rows in the scaled image.



$bestfit


Whether to fit the image inside a bounding box.





This function returns a TRUE on success.



  1 EXERCISE   

<?php

// Run several times

$img1 = new Imagick();

$jpgfn = PATH2IMGW . '/jpg/1.jpg';
$str1img = 'img/jpg/1r.jpg';

$img1->readImage($jpgfn);

$columns = mt_rand(1, 799);
$rows = mt_rand(1, 999);

$bestfit = mt_rand(0,1);

$legacy = mt_rand(0,1);

echo 
"adaptiveResizeImage($columns, $rows, $bestfit, $legacy);<br>";

$img1->adaptiveResizeImage($columns, $rows, $bestfit, $legacy);

$strg = $img1->getImageBlob();

$img = imagecreatefromstring($strg);

imagejpeg($img, $str1img);

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

 RESULT   


1.jpg

( Original Image )

130026 bytes

img/jpg/1.jpg apr

adaptiveResizeImage(632, 832, 0, 0);

1r.jpg

76828 bytes

img/jpg/1r.jpg apr


1.jpg

( Original Image )

130026 bytes

img/jpg/1.jpg apr

adaptiveResizeImage(962, 509, 0, 0);

1t.jpg

76044 bytes

img/jpg/1t.jpg apr