Both xyking and quickshiftin include errors in their comments. xyking's error is in looping through negative numbers. quickshifting is incorrect in stating that 0 *increases* contrast (it does not - it decreases it).
Here is a (tested, working) method to increment or decrement contrast:
<?php
class Images {
public function contrastImage($contrast, $imagePath){
$this->image = new Imagick();
$this->image->readImage($imagePath);
if ($contrast > 0){
for ($i = 1; $i < $contrast; $i++){
$this->image->contrastImage(1);
}
}else if ($contrast <= 0) {
for ($i = 0; $i > $contrast; $i--) {
$this->image->contrastImage(0);
}
}
}
}
?>