<?php
 class phMagick_color { function darken(phmagick $p ,$alphaValue = 50){ $percent = 100 - (int) $alphaValue; list ($width, $height) = $p->getInfo(); $cmd = $p->getBinary('composite'); $cmd .= ' -blend  ' . $percent . ' '; $cmd .= '"'.$p->getSource().'"'; $cmd .= ' -size '. $width .'x'. $height.' xc:black '; $cmd .= '-matte "' . $p->getDestination().'"' ; $p->execute($cmd); $p->setSource($p->getDestination()); $p->setHistory($p->getDestination()); return $p ; } function brighten(phmagick $p, $alphaValue = 50){ $percent = 100 - (int) $alphaValue; list ($width, $height) = $p->getInfo(); $cmd = $p->getBinary('composite'); $cmd .= ' -blend  ' . $percent . ' '; $cmd .= '"'.$p->getSource().'"'; $cmd .= ' -size '. $width .'x'. $height.' xc:white '; $cmd .= '-matte "' . $p->getDestination().'"' ; $p->execute($cmd); $p->setSource($p->getDestination()); $p->setHistory($p->getDestination()); return $p ; } function toGreyScale(phmagick $p, $enhance=2){ $cmd = $p->getBinary('convert'); $cmd .= ' -modulate 100,0 ' ; $cmd .= ' -sigmoidal-contrast '.$enhance.'x50%' ; $cmd .= ' -background "none" "' . $p->getSource().'"' ; $cmd .= ' "' . $p->getDestination() .'"'; $p->execute($cmd); $p->setSource($p->getDestination()); $p->setHistory($p->getDestination()); return $p ; } function invertColors(phmagick $p){ $cmd = $p->getBinary('convert'); $cmd .= ' "' . $p->getSource() .'"'; $cmd .= ' -negate '; $cmd .= ' "' . $p->getDestination() .'"'; $p->execute($cmd); $p->setSource($p->getDestination()); $p->setHistory($p->getDestination()); return $p ; } function sepia(phmagick $p, $tone = 90){ $cmd = $p->getBinary('convert'); $cmd .= ' -sepia-tone '. $tone .'% ' ; $cmd .= ' -modulate 100,50 ' ; $cmd .= ' -normalize ' ; $cmd .= ' -background "none" "' . $p->getSource() .'"' ; $cmd .= ' "' . $p->getDestination().'"' ; $p->execute($cmd); $p->setSource($p->getDestination()); $p->setHistory($p->getDestination()); return $p ; } function autoLevels(phmagick $p){ $cmd = $p->getBinary('convert'); $cmd .= ' -normalize ' ; $cmd .= ' -background "none" "' . $p->getSource().'"' ; $cmd .= ' "' . $p->getDestination() .'"' ; $p->execute($cmd); $p->setSource($p->getDestination()); $p->setHistory($p->getDestination()); return $p ; } } ?>