Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating/modifying images in JavaScript

Is it possible to dynamically create and modify images on a per pixel level in JavaScript (on client side)? Or has this to be done with server based languaged, such as PHP?

My use case is as follows:

  • The user opens webpage and loads locally stored image
  • A preview of the image is displayed
  • The user can modify the image with a set of sliders (pixel level operations)
  • In the end he can download the image to his local HDD

When searching in the web I just found posts about using IE's filtering method, but didn't find anything about image editing functions in JavaScript.

like image 229
Fabian Avatar asked Sep 17 '08 08:09

Fabian


3 Answers

Some browsers support the canvas: http://developer.mozilla.org/En/Drawing_Graphics_with_Canvas

like image 164
Aaron Jensen Avatar answered Oct 12 '22 23:10

Aaron Jensen


This has to be done on the server side. One thing you might look at doing is allowing all the editing to go on client side, and then in the end POST the final image (via AJAX) to the server to allow it to return it to you as the correct MIME type, and correctly packed.

like image 28
Sargun Dhillon Avatar answered Oct 13 '22 00:10

Sargun Dhillon


You may want to check out Processing.js. John Resig of jQuery fame wrote it. It supports pixel processing, unfortunately only Firefox 3 can handle it sufficiently.

like image 29
Jataro Avatar answered Oct 12 '22 23:10

Jataro