views:

6144

answers:

4

HI, Is there a way by which I can rotate an image inside a div clockwise or anticlockwise.

I have a main fixed width div[overflow set to hidden] with images loaded from database. There is a scroll bar for showing the images inside the div. When image is clicked then I need to show the rotating animation either in clockwise or anticlockwise direction.

I have done it using Matrix filter. I would like to know whether it is possible to be done in IE only without using any filters.

+3  A: 

The only way I can think of for rotating images on the client-side in IE is using filters. For somewhat recent versions the other browsers you can use the <canvas> control.

Your alternative is to use a server-side script to rotate the image. Then you can send the information on how to rotate it with JavaScript (i.e. generate a path to the image such as /rotate?image=img.jpg&amount=90)

Blixt
The problem with filters is that after applying the matrix filter the clarity of the image is reduced to some extend. Is there a way to avoid this??
rahul
+1  A: 

CSS3 supports rotation, but it isn't widely supported. As you asked for JavaScript solution, here's one, but I don't think you can get smooth images.

Michal M
Just a warning regarding the JavaScript solution: even for an image as small as 100x100, it'll generate 10,000 div elements, each with the image as their background. This is sure to bring down some browsers when doing it to larger images.
Blixt
+2  A: 

try this: http://raphaeljs.com/image-rotation.html

uses canvas but also supports IE

A: 

A small library that only rotates images (less than 3Kb Minified+gzipped)

http://wilq32.adobeair.pl/jQueryRotate/Wilq32.jQueryRotate.html

Wilq32