6

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.

7 Answers 7

8

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for all the comments. To summarize, there seem to be solutions for some browsers (e.g. Firefox). However, a solution for all browsers seems to require a server side implementation.
thanks for putting me on this. found a great primer in this answer stackoverflow.com/a/6634646/1382306 your answer should receive chk
2

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.

Comments

2

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.

Comments

1

Also look at data URIs (though IE versions below 8 don't support them, unfortunately!)

Comments

0

You can imagine a set of JS tools that will allow the user to define what kind of transformation he wants to do, but the final work of transformation MUST be done on a server side. JS on the client side is unable to create a file, for security reason.

Comments

0

Try Allicorn's Image Retargetter - it sounds like that's what you're looking for.

Comments

0

Local image manipulation in JavaScript should be possible - have a look at Defender of the Favicon. ;-) The question is how to get the original image from the file system into your page (I don't know of any other way than doing a HTTP upload to the server first).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.