phMagick color plugin

August 9, 2009 by nuno costa 5 comments

phMagick :: color functions

 

phMagick as a few color manipulation functions, see how they change this image

 

 

darken

<?php
 $p = new phmagick('original.png', 'destination.png');
 $p->darken(55);
?>

brigthen

<?php
 $p = new phmagick('original.png', 'destination.png');
 $p->brighten(55);
?>

grey scale

<?php
 $p = new phmagick('original.png', 'destination.png');
 $p->toGreyScale();
?>

invert colors

<?php
 $p = new phmagick('original.png', 'destination.png');
 $p->invertColors();
?>

sepia

<?php
 $p = new phmagick('original.png', 'destination.png');
 $p->sepia();
?>

auto levels

<?php
 $p = new phmagick('original.png', 'destination.png');
 $p->autoLevels();
?>

5 comments so far Add Your Comment

  1. by PHP Developer on January 17 2012 at 01:39

    Great piece of work..

  2. by SARAVANAN on February 27 2012 at 08:39

    phMagick: Error executing “convert -sepia-tone 90% -modulate 100,50 -normalize -background “none” “DSC_6734copy1.JPG” “dest/destination.JPG”"
    return code: 1
    command output :”convert: unrecognized option `-sepia-tone’.”

  3. by Rob on March 9 2012 at 07:57

    Nice code! This really simplified a script I was working on, it did in 5 min what took me 2 hours yesterday using GD.
    Only problem I can see is that it strips the color profile. The average person might not notice on most images, but as a photographer I notice right away. The vibrancy in the reds and yellows are gone from images with Adobe color profile (the browser shows the original picture with color profile). I know this only effects modern browsers.
    I want to edit the convert function to take account color profiles, but not yet familiar with imagemagick. This post on SO makes me think it is possible: http://stackoverflow.com/questions/2130196/how-do-i-remove-exif-tags-while-preserving-the-icc-color-profile, but I’m not sure how to extract the color profile…

  4. by nuno costa on March 12 2012 at 10:39

    @SARAVANAN, Please read this

  5. by Rob on March 14 2012 at 07:58

    I fixed my color space problem above by removing “$cmd .= ‘ -strip ‘;” from the resize function, works perfect now, thanks.

More from francodacosta.com

© francodacosta.com - All rights reserved