<?php // File and new size $filename = PATH_WWW.'img/degrade.png'; isset($_REQUEST['q'])? $percent = $_REQUEST['q'] : $percent = 0; $percent = $percent/100; // Get new dimensions list($width, $height) = getimagesize($filename); $new_width = $width * $percent; $new_height = $height; $image = new Imagick($filename); $image->cropImage($new_width, $new_height, 0, 0); $image->setImageFormat('png'); header('Content-type: image/png'); echo $image; ?>