Alter the Width of a Picture
Current Image (courtesy of Veronica Hutchins)
Select Width Change (-5 = Wider, 0 = No Change, 5 = Narrower)
SLAVE CODE FOLLOWS
<?php // narrow script
$narrow = $_GET['sk'];
// get the images from files
$image = imagecreatefromjpeg("../images/jason-leung-Xaanw0s0pMk-unsplash_sm.jpg");
// get sizes of original
$width_orig = imagesx($image);
$height = imagesy($image);
// adjust the width for the new image
$width = $width_orig - ($width_orig * $narrow * .05);
// create a new image
$new_image = imagecreatetruecolor($width, $height);
// resample old to new image
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height);
// set the header for the new image
header("Content-type: image/jpeg");
imagejpeg($new_image);
imagedestroy($new_image);
?>