JavaScript / PHP Image Manipulation: Phototype

19 January 2010 Tuesday

This application was viewed 1345 times




JavaScript / PHP Image Manipulation: Phototype

Phototype is a client/server-side image manipulation library, based on Prototype and supports all kinds of image manipulations.

Clientside JavaScript codes sends the commands to the serverside PHP – GD library image renderer and displays the rendered image.

Using Phototype, you are able to rotate, resize, flip and do some other cool effects to images.

Phototype: image manipulation with Javascript

Lately I had same crazy thoughts on coding a javascript wrapper to manipulate images rendered on the server-side. I decided to do some test which eventually resulted in phototype, a client/server-side library, based on prototype, which supports all kinds of image manipulations. On the serverside the library is powered by combination of PHP/GD that renders the image. With phototype, you are able to rotate, resize, flip and do some other cool effects to images. Let´s start a quick tour.

Suppose we have a picture like this (randomly grabbed from Flickr):

First, let´s reisize it:

  1. l_oPhoto = new Photo();
  2. l_oPhoto.resize({width:200});
  3. document.body.appendChild(l_oPhoto.fetch());

Pretty nifty eh? Note that the resizing is done serverside because usage of GD. Ok, let´s do some flipping:

  1. l_oPhoto = new Photo();
  2. l_oPhoto.resize({width:200});
  3. l_oPhoto.flipV(); // Flip vertical, use flipH to flip horizontal
  4. document.body.appendChild(l_oImage.fetch());

And rotate it some degrees:

  1. l_oPhoto = new Photo();
  2. l_oPhoto.resize({width:200});
  3. l_oPhoto.flipV();
  4. l_oPhoto.rotate(3); // rotate 3 degrees
  5. document.body.appendChild(l_oPhoto.fetch());

Drop shadow and make sketchy..

  1. l_oPhoto = new Photo();
  2. l_oPhoto.resize({width:200});
  3. l_oPhoto.flipV();
  4. l_oPhoto.rotate(3);
  5. l_oPhoto.dropShadow();
  6. l_oPhoto.makeSketchy();
  7. document.body.appendChild(l_oPhoto.fetch());

Or, make it greyscale?:

  1. l_oPhoto = new Photo();
  2. l_oPhoto.resize({width:200});
  3. l_oPhoto.flipV();
  4. l_oPhoto.rotate(3);
  5. l_oPhoto.dropShadow();
  6. l_oPhoto.toGreyScale();
  7. document.body.appendChild(l_oPhoto.fetch());

Adding a caption:

  1. l_oPhoto = new Photo();
  2. l_oPhoto.resize({width:200});
  3. l_oPhoto.rotate(3);
  4. l_oPhoto.dropShadow();
  5. l_oPhoto.addCaption(´Get ajaxorized!´, ´1942.ttf´);
  6. document.body.appendChild(l_oPhoto.fetch());

And finally, because we can´t live without Chuck Norris :-):

  1. l_oPhoto = new Photo();
  2. l_oPhoto.resize({width:200});
  3. l_oPhoto.rotate(3);
  4. l_oPhoto.dropShadow();
  5. l_oPhoto.addCaption(´Cheers, Chuck´, ´1942.ttf´);
  6. l_oPhoto.addChuckNorris(); // every library should have this function imo
  7. document.body.appendChild(l_oPhoto.fetch());

Chaining
Phototype supports chaining:

  1.  
  2. l_oPhoto = new Photo().load("test.jpg").dropShadow().flipH().makeSketchy();
  3. document.body.appendChild(l_oPhoto.fetch());
  4.  

 

Tags: javaScript, php, image, phototype,


JavaScript / PHP Image Manipulation: PhototypeBookmark and Share

You write your thoughts

Please login to post comments here from the right corner.

your add
icon free icon icon set vector icon free catalog catalog template jquery news ticker widget tools tutorial php slider video youtube effects menu thumbnail forms facebook zoom image combo multiselect modal polaroid gallery expand code feedback contact navigation slider tagcloud Skateboard psd templates files badges subscribe panel login temlate file free office holland free template tabs prototype css scriptaculous opacity moo autocomplete wordpress themes design theme button images photoshop fonts font nav pdf logo style high javascript pretty photo jqery lightbox Themes Blog popular blog desing joomla xhtml brushes hair footer admin mootols slide show blackbox new download class first plugin upload browse Page effect modalbox web application urlitooltips sliding boxes captions flatchat chat ajax messaging browser hoverlightbox CSS Dev General Javascript PHP SQL search avatar vector Drupal Joomla Oscommerce javaScript phototype manager ajaxplorer flash xml rotator bookmarking pageflip slideshow poll text component script mediaplayer imagegallery pictograms car poster player mp3 radio onlineradio navigations drop-down collection brush tree textures paper pop-up bumpbox web2.0 iphone film frame twitter page fan mail delete dynamic calender form handbook city social paint timeline clock connect bar sharing accordion quotes ticker photo-effects background 3D media player graphic rss leaf green glossy bubble icon comic clean cool web 2.0 png actionscript ietter rotating Menu animated textured site masking pasword app layer sponge bob popup bubble tooltips horizontal prototip tooltip pack charachters comics blog action icon.psd flavour navi tango gradients istanbul mixed css3 sleek animations program html5 website Layer styles ultimate candy Media icons dropdown snow icon innerfade hover sub tag