views:

1244

answers:

2

We currently have a system for cropping images that uses jCrop on the front-end, and System.Drawing in .NET on the backend - this works very well, but now we need to introduce image rotation. Only 90 degree angles are needed, and jQuery.Rotate works fine in isolation, but I would like to combine these two jQuery plugins gracefully. Do you have any experience in this area? Are there "shake & bake" solutions?

A: 

I think jQuery pipe-lining is the answer for any jQuery plugin

for example:

$("image").rotate(foo).crop(foo);
Ahmed Khalaf
I'm afraid this won't work. Both jCrop and jQuery-Rotate make substantial changes to the DOM; they need to integrate in some way. As a last resort I could split the rotation and cropping over several steps, but I'd rather keep them in together.
Daniel Schierbeck
Pipelining.. doesn't exist in jQuery. Every function just returns a `jQuery` object.
Dykam
for Dykam: and this is what we call pipe-lining :D, you can pipeline more than one operationfor Daniel: you are right, but we still can find a solution... i liked this problem and will post another answer if i find one
Ahmed Khalaf
I believe the correct term is "chaining" not "pipe-lining"
zachleat
A: 

Since the two plugin-ins operate in very different ways, I don't think you can readily combine the two. jCrop simply allows you to define a rectangular marquee over an image. Rotation, on the other hand, either uses <canvas> to actually rotate the image or the DXImageTransform filter to show it rotated (not actually rotating the source image.)

Ates Goral
on IE Rotation is done with angle attribute, which means you can do rotation and then jCrop
Ahmed Khalaf
What angle attribute? The official site of jquery-rotate (http://code.google.com/p/jquery-rotate/) states: Two JavaScript image handling implementations are supported: 1. using DXImageTransform filter for Microsoft Internet Explorer 2. using Canvas object for other browsers
Ates Goral
yes, and the filter is applied with css, so it's achievable to rotate then jCrop after applying the rotation
Ahmed Khalaf
I still don't think that will work. Firstly, the filter is only used on IE. What about FF? Also, if the crop plug-in is reading the image's dimensions, they won't change with the CSS filter; CSS only changes the presentation of the image. If you still think this is doable, I think the onus is on you to write a working demo :)
Ates Goral