Basic Mechanics

August 10, 2009 by nuno costa 3 comments

Basic Mechanics

phMagick philosophy is extremely simple, you say where is the source image and where you want the new image and then apply actions to it
One great feature of phMagick is that you can apply several actions to an image, making it extremely powerful and able to create very complex images

In the combination example you will see how easy it is to create a thumbnail with rounded corners and then applying a drop shadow to it.

Enough talking, let’s look at some example code to see its simplicity

1
2
3
    include "phMagick.php";
    $p = new phMagick("source.png","destination.png");
    $p->rotate(45);

In the first line we tell PHP that we are using a file named phMagick.php, it’s were phMagick is declared, you only need to do this once.
Line 2 creates a phMagick instance, and say that source.png will be our source image and destination.png will be the new image
Line 3 does the magic, in this case rotates source.png 45 degrees and saves it as destination.png

3 comments so far Add Your Comment

  1. by Joel on January 27 2010 at 19:10

    Hi – this looks like a great library. I’m wondering – does this handle uploading at all? Or does there already have to be an image on the server for it to do anything with it?

    Thanks!

  2. by nuno costa on January 29 2010 at 21:46

    No, it only handles image manipulation

  3. by Cloud on March 1 2010 at 00:36

    @Joel

    Hi but u can combine it with swfupload and the swfobject works 4 me and my private projects.

    And needless to say big TY to nuno costa

More from francodacosta.com

© francodacosta.com - All rights reserved