Details
| Version | 1.2.2 |
|---|---|
| Last updated | 4th July 2011 |
| Requirements |
|
| Demo | View demo page |
| Links | |
| License | BSD License |
| Changelog |
|
About
The JavaScript image cropper UI allows the user to crop an image using an interface with the same features and styling as found in commercial image editing software, and is is based on the Prototype JavaScript framework and script.aculo.us.
Initially I performed quite a lot of searching for some ready made solutions to meet my requirements, but found none that had the complete feature set that I required or any complete versions based on Prototype.
So after a week and a half of work, I present the JavaScript image cropper UI, built on Prototype & script.aculo.us.
Features
![]()
- Un-obtrusive
- Based on Prototype and script.aculo.us
- Image editing package styling & functionality, the crop area functions and looks like those found in popular image editing software
- Dynamic inclusion of required styles
- Drag to draw areas
- Shift drag to draw/resize areas as squares
- Selection area can be moved
- Selection area can be resized using resize handles
- Allows dimension ratio limited crop areas
- Allows minimum dimension crop areas
- Allows maximum dimensions crop areas, if both min & max set as the same value then we'll get a fixed cropper size on the axes as appropriate and the resize handles will not be displayed as appropriate
- Allows dynamic preview of resultant crop (if minimum width & height are provided), this is implemented as a subclass so can be removed if not required
- Movement of selection area by arrow keys (shift + arrow key will move selection area by 10 pixels)
- All operations stay within bounds of image
- All functionality & display compatible with most popular browsers supported by Prototype, tested in:
- PC: IE 6 & 5.5, Firefox 1.5, Opera 8.5 (see known issues) & 9.0b
- MAC: Camino 1.0, Firefox 1.5, Safari 2.0
Usage
Extract to a directory of your choosing e.g. 'scripts/cropper/' and include the script and the required Prototype & script.aculo.us scripts:
-
<script type="text/javascript" src="scripts/cropper/lib/prototype.js" language="javascript"></script>
-
<script type="text/javascript" src="scripts/cropper/lib/scriptaculous.js?load=effects,builder,dragdrop" language="javascript"></script>
-
<script type="text/javascript" src="scripts/cropper/cropper.js" language="javascript"></script>
Options
- ratioDim obj
- The pixel dimensions to apply as a restrictive ratio, with properties x & y.
- minWidth int
- The minimum width for the select area in pixels.
- minHeight int
- The mimimum height for the select area in pixels.
- maxWidth int
- The maximum width for the select areas in pixels (if both minWidth & maxWidth set to same the width of the cropper will be fixed)
- maxHeight int
- The maximum height for the select areas in pixels (if both minHeight & maxHeight set to same the height of the cropper will be fixed)
- displayOnInit int
- Whether to display the select area on initialisation, only used when providing minimum width & height or ratio.
- onEndCrop func
- The callback function to provide the crop details to on end of a crop.
- captureKeys boolean
- Whether to capture the keys for moving the select area, as these can cause some problems at the moment.
- onloadCoords obj
- A coordinates object with properties x1, y1, x2 & y2; for the coordinates of the select area to display onload
The callback function
The callback function is a function that allows you to capture the crop co-ordinates when the user finished a crop movement, it is passed two arguments:
- coords, obj, coordinates object with properties x1, y1, x2 & y2; for the coordinates of the select area.
- dimensions, obj, dimensions object with properities width & height; for the dimensions of the select area.
An example function which outputs the crop values to form fields:
-
function onEndCrop( coords, dimensions ) {
-
$( 'x1' ).value = coords.x1;
-
$( 'y1' ).value = coords.y1;
-
$( 'x2' ).value = coords.x2;
-
$( 'y2' ).value = coords.y2;
-
$( 'width' ).value = dimensions.width;
-
$( 'height' ).value = dimensions.height;
-
}
Basic interface
This basic example will attach the cropper UI to the test image and return crop results to the provided callback function.
Minimum dimensions
You can apply minimum dimensions to a single axis or both, this example applies minimum dimensions to both axis.
Select area ratio
You can apply a ratio to the selection area, this example applies a 4:3 ratio to the select area.
-
<img src="test.jpg" alt="Test image" id="testImage" width="500" height="333" />
-
-
<script type="text/javascript" language="javascript">
-
Event.observe( window, 'load', function() {
-
new Cropper.Img(
-
'testImage',
-
{
-
ratioDim: {
-
x: 220,
-
y: 165
-
},
-
displayOnInit: true,
-
onEndCrop: onEndCrop
-
}
-
);
-
} );
-
</script>
With crop preview
You can display a dynamically produced preview of the resulting crop by using the ImgWithPreview subclass, a preview can only be displayed when we have a fixed size (set via minWidth & minHeight options). Note that the displayOnInit option is not required as this is the default behaviour when displaying a crop preview.
-
<img src="test.jpg" alt="Test image" id="testImage" width="500" height="333" />
-
<div id="previewWrap"></div>
-
-
<script type="text/javascript" language="javascript">
-
Event.observe( window, 'load', function() {
-
new Cropper.ImgWithPreview(
-
'testImage',
-
{
-
previewWrap: 'previewWrap',
-
minWidth: 120,
-
minHeight: 120,
-
ratioDim: { x: 200, y: 120 },
-
onEndCrop: onEndCrop
-
}
-
);
-
} );
-
</script>
Known Issues
- Safari animated gifs, only one of each will animate, this seems to be a known Safari issue.
- After drawing an area and then clicking to start a new drag in IE 5.5 the rendered height appears as the last height until the user drags, this appears to be the related to another IE error (which has been fixed) where IE does not always redraw the select area properly.
- Lack of CSS opacity support in Opera before version 9 mean we disable those style rules, if Opera 8 support is important you & you want the overlay to work then you can use the Opera rules in the CSS to apply a black PNG with 50% alpha transparency to replicate the effect.
- Styling & borders on image, any CSS styling applied directly to the image itself (floats, borders, padding, margin, etc.) will cause problems with the cropper. The use of a wrapper element to apply these styles to is recommended.
- overflow: auto or overflow: scroll on parent will cause cropper to burst out of parent in IE and Opera when applied (maybe Mac browsers too) I'm not sure why yet.
Next Steps
Feature Requests & Bug Reports
Please check the existing list of feature requests & bugs and the discussion list before posting requests or reporting bugs.
Leave a Tip
If you find this code useful you can leave a donation towards the continued development & support.
Comments
There have been 750 comments so far, join the discussion.
Pages: « 1 2 3 [4] 5 6 7 8 9 10 11 … 15 » Show All
151. bjarke - 9th Jan 2007 - 2:40 pm
Hi Dave.
I use the remove() function. Is it not the one to use?
152. Dave - 9th Jan 2007 - 3:01 pm
bjarke:
The remove() method is the correct one to use, I’m guessing this could be a new bug, possibly a browser related issue. Does your example work in any browser? If you could provide some more information and possibly an example then I will be able to explore this further.
153. bjarke - 10th Jan 2007 - 9:23 am
The problem only occurs in IE 7. In Firefox there is no problem! The flow is as follows:
I execute the LoadCropper-function, and the cropper works fine. I execute the LoadCropper-function again and picture goes all white. If I click inside the white area where the picture should be, it turns grey.
The Code:
var CropObject = null;
function LoadCropper()
{
if( CropObject == null )
{
CropObject = new Cropper.Img( ‘target-img’, { onEndCrop: onEndCrop } );
}
else
{
CropObject.remove();
CropObject = null;
CropObject = new Cropper.Img( ‘target-img’, { onEndCrop: onEndCrop } );
}
}
I hope this helps.
Best regards Bjarke
154. Bryan - 10th Jan 2007 - 9:17 pm
Same problem as bjarke. Had it since 1.1. Works in FF, but not in IE6/7. The image loads, and then the cropper makes the image all white (like a non-transparent overlay). You can create a grey crop box.
155. fialik - 18th Jan 2007 - 11:14 am
I have the nearly the same problem as byarke and brian. If I directly call the cropper contstructor to create a cropper object, everything is working fine. Also in IE7. But if I set the constructor in a JavaScript-method and execute this method, the image is gettig white. It is also possible to crop a part out of the image, because alle the coordinates are working fine, but it’s a kind of difficult to crop out something of an image you can not see :)
156. fialik - 18th Jan 2007 - 12:03 pm
I solved the problem, in my case. I had another div layer with a oppacity of 40% (IE filter:alpha(opacity=40)). Before I created the croper object, I changed the class of this div to a class with no oppacity. I think that the IE then set the global alpha filter value back to 100 and so all other, already loaded, style settings are been overwritten. I now created a overlay div with an opacity of 40%, but I only switch the whole visibility value between “visible” and “hidden”. Ik works fine in IE6, IE7 and Firefox2 now.
157. Pete Frueh - 19th Jan 2007 - 6:03 pm
Like you, I couldn’t find a browser-based image editor when I needed one, so I ended up creating my own (http://www.ajaxprogrammer.com/?p=9).
I can’t wait to take a peek at your code :-)
Cheers,
Pete Frueh
158. Stranger - 23rd Jan 2007 - 9:05 am
Hi,
i found some cropper butthis one is great. I write some code to change the area dynamicaly via selectbox. If i select 200×200 (ratio) the croparea displayed on the image. If i select a second one (4:3), the new croparea displayed over the old one and the image goes darker.
How i can remove the old croparea?
here is some code ([ = ):
function onEndCrop( coords, dimensions ) {
$( ‘x1’ ).value = coords.x1;
$( ‘y1’ ).value = coords.y1;
$( ‘x2’ ).value = coords.x2;
$( ‘y2’ ).value = coords.y2;
$( ‘width’ ).value = dimensions.width;
$( ‘height’ ).value = dimensions.height;
}
function loadExample( type ) {
switch( type ) {
case( ‘200×200’ ) :
new Cropper.Img( ‘testImage’, { ratioDim: { x: 220, y: 200 }, minWidth: 220, minHeight: 200, displayOnInit: true, onEndCrop: onEndCrop } );
break;
case( ‘4:3’ ) :
new Cropper.Img( ‘testImage’, { ratioDim: { x: 220, y: 165 }, displayOnInit: true, onEndCrop: onEndCrop } );
break;
case( ‘basic’ ) :
default :
new Cropper.Img( ‘testImage’, { displayOnInit: true, onEndCrop: onEndCrop, onloadCoords: { x1: 10, y1: 10, x2: 250, y2: 100 } } );
}
}
[form action=”test.php” enctype=”multipart/form-data” method=”post” name=”form”][img src=”castle.jpg” alt=”testImage” id=”testImage” width=”800” height=”600”]
[input type=”hidden” name=”x1” id=”x1”]
[input type=”hidden” name=”y1” id=”y1”]
[input type=”hidden” name=”x2” id=”x2”]
[input type=”hidden” name=”y2” id=”y2”]
[input type=”hidden” name=”width” id=”width”]
[input type=”hidden” name=”height” id=”height”]
[select id=”type” name=”type” onchange=”loadExample( this.options[this.selectedIndex].value )”]
[option value=”—-” selected=”selected”]please select an ratio[/option]
[/select]
[input type=”submit” name=”submit” value=”cut it!”]
[/form]
159. Sangeetha S - 23rd Jan 2007 - 12:09 pm
The programs are very excellent.
I want to know abt moving the arrow keys over the image,in several .js files,in which file the movement of arrow keys have been mentioned.Thanks in advance.
160. Stranger - 23rd Jan 2007 - 2:32 pm
Hi folks,
i changed my code but the croparea dosn’t change if i change the selectfield! Can someone check my syntax, please?
var CropImageManager = {
curCrop: null,
init: function() {
this.attachCropper2();
},
onChange: function( e ) {
this.attachCropper2( e );
},
attachCropper2: function( r ) {
if( this.curCrop null ) {
if( r “200×200fixed” ) {
this.curCrop = new Cropper.Img( ‘testImage’, { ratioDim: { x: 220, y: 200 }, minWidth: 220, minHeight: 200, maxWidth: 220, maxHeight: 200, displayOnInit: true, onEndCrop: onEndCrop } );
} else if( r "200x200" ) {
this.curCrop = new Cropper.Img( 'testImage', { ratioDim: { x: 220, y: 200 }, minWidth: 220, minHeight: 200, displayOnInit: true, onEndCrop: onEndCrop } );
} else if( r “4:3” ) {
this.curCrop = new Cropper.Img( ‘testImage’, { ratioDim: { x: 220, y: 165 }, displayOnInit: true, onEndCrop: onEndCrop } );
} else if( r == “16:9” ) {
this.curCrop = new Cropper.Img( ‘testImage’, { ratioDim: { x: 220, y: 124 }, displayOnInit: true, onEndCrop: onEndCrop } );
} else {
this.curCrop = new Cropper.Img( ‘testImage’, { displayOnInit: true, onEndCrop: onEndCrop, onloadCoords: { x1: 10, y1: 10, x2: 250, y2: 100 } } );
}
} else {
this.curCrop.reset();
}
}
};
function onEndCrop( coords, dimensions ) {
$( ‘x1’ ).value = coords.x1;
$( ‘y1’ ).value = coords.y1;
$( ‘x2’ ).value = coords.x2;
$( ‘y2’ ).value = coords.y2;
$( ‘width’ ).value = dimensions.width;
$( ‘height’ ).value = dimensions.height;
}
Event.observe( window, ‘load’, function() {
CropImageManager.init();
Event.observe( $(‘typ’), ‘change’, CropImageManager.onChange.bindAsEventListener( CropImageManager ), true );
} );
The selectfield has the id=typ name=typ!
161. Markit - 27th Jan 2007 - 11:36 pm
This is an Excellent App, but I found a bug!
If you use the keypad to move the Boundbox, then onEndCrop is never executed unless you click on it afterwards
162. Simon - 2nd Feb 2007 - 10:17 pm
Nice! Is it possible to change aspect ratio, remove aspect ratio without reloading the page?
163. amzad - 10th Feb 2007 - 11:35 am
using this DocType in my HTML page
Drag Drop
Not work in firefox
164. Rainer Schleevoigt - 13th Feb 2007 - 9:51 am
After realisation of a cropper in combination with convert http://familientagebuch.de/rainer/2006/50.html#5 we now finished a creater of USEMAPs with this technique (http://familientagebuch.de/rainer/2006/51.html#4). In future we plan to crop a polygon from a picture.
Rainer
165. Kristinn S. - 19th Feb 2007 - 7:55 am
First of all I would like to thank you David for this awesome plugin.
Though this might help someone…
While trying to make some changes to this plugin I changed the loaded script to cropper.uncompressed.js, and noticed that suddenly the cropper wasn’t working. Took me some time to notice that on line 356 there is a regular expression which only matches “cropper.js”, so for developers you might want to change line 356 & 357 to:
if( s.src.match( /cropper(\.uncompressed)?\.js/ ) ) {
var path = s.src.replace( /cropper(\.uncompressed)?\.js(.*)?/, ‘’ );
this will match “cropper.js” & “cropper.uncompressed.js”, which would make the stylesheet cropper.css load properly.
and thanks again for this, saved me TONS of work!
166. Matt Barnicle - 24th Feb 2007 - 12:47 am
Great app, truly amazing.. I’ve been modifying it to adapt to our specific needs. I’m actually building an interface to use this as a resizer instead of a cropper. So it loads up the image inside of the dotted line interface and when you resize it, the image resizes with it. It’s working well, but I have one question I can’t figure out so far. Is there a way to disable the user from being able to draw another resize box? That would break the flow of our interface. Should be easy if I know what I’m doing, but I can’t seem to figure it out..
– Matt
167. Dave - 25th Feb 2007 - 6:15 pm
All:
Sorry for the very late response to some of your posts and questions, I’ve been busier than usual lately.
Simon:
It is possible to change the aspect ratio without reloading the page, however you have to remove & re-add the cropper to do this.
Kristinn:
Thanks for your kind words about the cropper I’m glad it has proved helpful to you. Also thanks for the heads up on the little bug, I work with a cropper.js file and then the ANT scripts compress it for the release and rename the original to cropper.uncompressed.js – which is why I’ve never come across the bug.
Matt:
Thanks for your kind comments, you should easily be able to remove the ability to draw a new crop (resize in your case) area by removing the event listener on the drag pane. Can’t remember exactly without digging into the code, if you need any more help just ask.
Once again thank you all for your kind comments about the cropper.
168. Bjarke - 26th Feb 2007 - 10:04 am
The problem only occurs in IE 7. In Firefox there is no problem! The flow is as follows:
I execute the LoadCropper-function, and the cropper works fine. I execute the LoadCropper-function again and picture goes all white. If I click inside the white area where the picture should be, it turns grey.
The Code:
var CropObject = null;
function LoadCropper()
{
if( CropObject == null )
{
CropObject = new Cropper.Img( ‘target-img’, { onEndCrop: onEndCrop } );
}
else
{
CropObject.remove();
CropObject = null;
CropObject = new Cropper.Img( ‘target-img’, { onEndCrop: onEndCrop } );
}
}
I hope this helps.
Best regards Bjarke
169. Sommerschwede - 27th Feb 2007 - 5:53 pm
hello!
is there an way to have two or more Previews (ImgWithPreview) (differnt skalings/sizes) of one crop?
170. Dave - 27th Feb 2007 - 6:29 pm
Sommerschwede:
This is possible, but not out of the box. I have seen someone demo this and I believe it is somewhere in the comments.
171. Matt Barnicle - 28th Feb 2007 - 12:27 am
Hi Dave, everyone.. I’ve completed a proof of concept for my work. I made some additions to the cropper.js that may very well be useful to some people. First, an overview of what our app needed..
We needed an interface to upload a larger photo (gt or equal to 640×480), choose an area of the photo to scale down to 400×300 (could be the entire image uncropped), then take a selection of that scaled down image to make a thumbnail. That thumbnail has certain restrictions on it, and we needed more flexibility in the preview pane, so I had to add some things to the code…
So, I disabled the listener on the drag pane, per Dave’s suggestion (thanks Dave). And I added some config options as outlined below:
You can see a demo here:
http://gattomatto.net/work/jsCropperUI/
This demo includes backend PHP code that does the cropping and redisplays the cropped images. View the source to find the location of cropper.js which I modified to support these features.
Feel free to copy this file and offer any feedback on this. As this will be an important part of the code library on our site, I welcome critiques to make the code better.
– Matt
172. Matt Barnicle - 28th Feb 2007 - 12:31 am
Made a mistake on my last post..
“disableCropPreview (boolean) – Only useful when displayOnInit is true”
should read:
“disableCropRedraw (boolean) – Only useful when displayOnInit is true”
173. Dave - 28th Feb 2007 - 10:23 am
Matt:
That’s a pretty sweet implementation, although I was a little confused with the second step (when making the thumbnail) until I realised what limits were in place on the dimensions.
I haven’t had chance to look at the code yet but there may be some features I might feed into the original, although I also had an idea to have a section which linked to customised versions of the script.
I’m glad you found it useful and hope it was fairly straight forward to customise to your needs.
174. arginin - 1st Mar 2007 - 2:25 pm
Hello,
I work with the cropper. I want crop mutilple pictures on one page. Support the cropper that? On the Bug/Featurelist I found following entry:
00015 – Test with multiple croppers (see comment by Luis Bolson)
Where can I find the comment from Luis Bolson?
Thanks for help
175. Dan - 2nd Mar 2007 - 11:21 am
Great work Dave, brilliant. I have a little bug that I just cant figure out.
If i set minwidth/height or set displayoninit when i have set ratioDim then I get a black image and just the selection is 0 opacity but i get 50% opacity along the X-Axis. Basically anything above or below the selection is black.
I am using IE7 and the code I am using is virtually identical to your examples.
176. Dan - 2nd Mar 2007 - 11:27 am
Found an issue that I can reproduce on your imagepreview samples. If you turn off “displayOnInit: true, ” then the preview never appears.
177. Dan - 2nd Mar 2007 - 11:55 am
I fixed most of my issues by removing all the tables, so the div for the image editing is on its own inside the body tag. If its any table cells it just doesnt work right and there are loads of different issues (white with grey, black, nothing appearing etc).
178. Raanan Avidor - 5th Mar 2007 - 2:30 pm
Hi.
Great app! Is there a way that when you hit Enter the crop will take place?
179. Dave - 5th Mar 2007 - 3:31 pm
Raanan:
It would be a fairly simple addition to make the cropper submit the form when a user presses enter, you should be able to make it some part of the callback etc. and just have an event observer on the cropper.
However thinking this through as I type my answer, you’d have to be sure that the user was interacting with the cropper and not with any other part of the page; if that is the sole role of your page (just cropping an image) then that would be fine. I don’t think this is something that I would add this to the release version because of that complexity (unless a few more people request the feature).
Hope that helps.
180. Dan - 5th Mar 2007 - 3:33 pm
Or indeed (like graphic apps), getting a callback when the crop is double-clicked so we can perform a server crop function.
181. Dave - 5th Mar 2007 - 3:41 pm
Dan:
A double click would work, and is something I could potentially add to the release version (as you’d be sure that the user was within the cropper) – I suppose if I add that then I could add an alternative option for the enter key to do the same callback.
However I’m still not sure whether this feature would be used by only the minority of people using the cropper and I don’t want to bloat the base release with features like this if it’s not going to be used in the majority of implementations.
182. Dan - 5th Mar 2007 - 4:24 pm
I totally understand Dave. It was the first thing I tried when i used it, I just expected a double-click to do my crop because thats what all gfx programs do. Its not necessary or highly important, but it is the norm.
Only other posters could verify the importance of such a feature.
Thanks again Dave
183. Rob - 8th Mar 2007 - 3:35 pm
HI,
Ive been having a hell of a time trying to get the cropper to work. I have literally copied and pasted the Cropper Demo page an I have had no success making it work.
If anyone could have a look at it I would really appreciate it.
http://lloveras.org/cropper/test.html
Any one have an idea why it doesnt work?
184. Bjoern - 8th Mar 2007 - 3:53 pm
Hi,
great work first of all :-)
Would be cool to have an zooming function like here:
http://mypictr.com/
Bye,
Bjoern
185. Dave - 8th Mar 2007 - 4:27 pm
Rob:
I can see that the CSS file is not been loaded as it doesn’t exist, that could possibly be the problem.
186. Darrell Esau - 8th Mar 2007 - 11:36 pm
Great work.
I’m having one issue that I’ve reproduced in Firefox, Safari and IE:
Everything works great, except when I’ve created a crop rectangle, then try to move the selected area by clicking and dragging. It just reselects another area. Any hints?
187. Dave (Different One) - 12th Mar 2007 - 2:28 am
Hya,
Just wondered if you’d got anywhere with the overflow issue, or if you’ve got any ideas why and i’ll dig around and see if i can fix it.
Thanks
Dave
188. Felix - 12th Mar 2007 - 4:03 am
I just wanted to say thanks!
189. Daniel - 13th Mar 2007 - 3:22 am
Anyway to give the grab boxes some more grab-space? It requires a lot of mouse control when they’re that small.
190. Dave - 13th Mar 2007 - 10:01 am
Daniel:
If memory serves me correctly the handles are just sized and positioned via the CSS so you should be able to change them quite easily.
Dave:
No I’ve not got any further with the overflow issue, I had fixed it completely in Firefox but in IE and Opera the image burst (from a rendering terms, not in the DOM) out of the overflow element when I apply the cropper.
This only happens when I dynamically alter the DOM at runtime, if the HTML that the script inserts is there when the page loads then it is fine in both IE and Opera, this makes absolutely no sense and I couldn’t find a work around to it – I eventually just had to take a break from trying to fix that issue as it was driving me crazy. I can dig out my old test cases and let you have a play if you want.
191. Dave (Different One) - 15th Mar 2007 - 1:24 pm
Dave
tap dances gleefully
ok, the IE/Opera overflow bug….FIX!!!
such a pain in the arse to find, so simple a fix. You need to add ‘position:relative’ to the image container.
I’ve tested this in the latest version if IE/Firefox/Opera and it works a treat. I thought about having cropper.js do it onLoad, but wasn’t sure if you wanted to mess with the container as its a user defined element.
Anyhow, I didn’t say before, so I’ll say it now, excellent script :).
Also, I’ve written an asp.net backend cropper if anyone wants an alternative to the PHP ones out there.
Thanks Muchly
Dave
192. Dave - 15th Mar 2007 - 11:30 pm
Dave:
Congratulations on fixing the bug, really well done.
As you say I doubt this is something that I would add to the script itself, maybe only as a note in the usage instructions – as I can’t reliably be messing around with any elements that the script doesn’t create itself.
Well done again.
193. Sergey Koksharov - 16th Mar 2007 - 6:56 am
Hey! It’s a really cool cropper. It was surprise for me to knew about that tool cause I did somthing like on http://marqueetool.net
Dave, may be we will cooperate and will create some more powerfull cropper (marquee) or something else? ;)
Regards, Sergey Koksharov
194. TheIceman5 - 18th Mar 2007 - 2:00 am
i have a problem with it when i use it in layers, “advanced layer popup” to be exact. http://www.dmxzone.com/ShowDetail.asp?NewsId=12769
when the crop script is put in the layer popup and run from there, when you go and crop the image in internet explorer 6 or 7 the crop area i like an xray and puts a hole through the layers to the page underneath. anyone give me any advice on how to correct this problem?
the demo above works fine, just when you combine the cropper and popup layer is where the problem starts with the xray.
Fulld etails are here in this thread on this forum below.
can anyone help me out here??
http://phpbuilder.com/board/showthread.php?t=10337256
195. Daniel - 19th Mar 2007 - 1:35 am
When using the preview, if you dynamically change the image source, the preview is not updated. This may sound like a rare event, but in my case I run graphical filters on demand and wrap the img src on complete.
I added a method that resets the preview. For anyone in need, here’s all it takes:
resetPreview: function() {
this.subInitialize();
this.subDrawArea();
}
196. Chris - 20th Mar 2007 - 4:47 pm
Hi,
I want to use a fix size rectangle:
displayOnInit: true,
minWidth: 120,
minHeight: 120,
maxWidth: 120,
maxHeight: 120,
onEndCrop: onEndCrop
But I can resize the rectangle. The min works but not the max.
Can someone help me, please?
Regards
Chris
197. riya - 22nd Mar 2007 - 3:26 am
Can anyone give example on how to use “onloadCoords” for the coordinates of the select area to display onload?
Thanks.
Riya
198. Craig - 23rd Mar 2007 - 8:29 pm
Ok I need help here. I need to figure out how to save the preview thumbnail to a file. I have the cropper working using a dynamic source and I need to be able to save the area selected to a jpg. I know this cropper is just the UI but I need to understand how to past the information to a PHP script to do something like imagecreate( ). I’m not very good with JS. So if someone could help that would be great.
Thanks
199. Leif - 23rd Mar 2007 - 10:23 pm
Okay, so this is nice. Once you have the area you want cropped on an image located in your server directory, how do you actually crop it and resize it to that. Say I want to resize it to whatever the preview looks like and resave that image file.
200. Leif - 23rd Mar 2007 - 10:26 pm
I guess I’m with Craig on this one. Also, is there a way to crop the image first without actually uploading it to the server and then save the preview thumbnail as an image to the server once submitted?
Leave a comment
No HTML please, only textile. For code please use [lang]...[/lang] tags (e.g. [html]...[/html] for HTML)