Details

Version 1.2.2
Last updated 4th July 2011
Requirements
Demo View demo page
Links
License BSD License
Changelog
1.2.2
  • Support for latest versions of Prototype & script.aculo.us (1.7.0 & 1.9.0 respectively)
  • Tested with & added support notice for IE9
1.2.1
  • Added support for latest versions of Prototype & script.aculo.us (1.6.1.0 & 1.8.2 respectively). Changes provided by Tom Hirashima.
  • No-longer package prototype & script.aculo.us with the release
  • Changed tests to use google ajax libraries api to load prototype & script.aculo.us
  • Added option to not auto include the cropper CSS file
  • #00008 - Fixed bug: Dynamic include of cropper CSS expected cropper.js and failed when using cropper.uncompressed.js
  • #00028 - Fixed bug: Doesn't work with latest script.aculo.us - Fix by Tom Hirashima
  • #00030 - Fixed bug: Doesn't work in Firefox 3.5 (CSS include issue)
  • #00007 - Fixed bug: onEndCrop isn't called when moving with keys
  • #00011 - Fixed bug: The image that is to be cropped does not show in IE6.0 -- included CSS fix
  • Tidied up source code & fixed issues that jslint found so it will compress better
1.2.0
  • Added id to the preview image element using 'imgCrop_[originalImageID]'
  • #00001 - Fixed bug: Doesn't account for scroll offsets
  • #00009 - Fixed bug: Placing the cropper inside differently positioned elements causes incorrect co-ordinates and display
  • #00013 - Fixed bug: I-bar cursor appears on drag plane
  • #00014 - Fixed bug: If ID for image tag is not found in document script throws error
  • Fixed bug with drag start co-ordinates if wrapper element has moved in browser (e.g. dragged to a new position)
  • Fixed bug with drag start co-ordinates if image contained in a wrapper with scrolling - this may be buggy if image has other ancestors with scrolling applied (except the body)
  • #00015 - Fixed bug: When cropper removed and then reapplied onEndCrop callback gets called multiple times, solution suggestion from Bill Smith
  • Various speed increases & code cleanup which meant improved performance in Mac - which allowed removal of different overlay methods for IE and all other browsers, which led to a fix for:
  • #00010 - Fixed bug: Select area doesn't adhere to image size when image resized using img attributes
  • #00006 - Removed default behaviour of automatically setting a ratio when both min width & height passed, the ratioDimensions must be passed in
  • #00005 - Added ability to set maximum crop dimensions, 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
  • Switched keydown for keypress for moving select area with cursor keys (makes for nicer action) - doesn't appear to work in Safari
1.1.3
  • Fixed wrong cursor on western handle in CSS
  • #00008 & #00003 - Added feature: Allow to set dimensions & position for cropper on load
  • #00002 - Fixed bug: Pressing 'remove cropper' twice removes image in IE
1.1.2
  • Fixed bugs with ratios when GCD is low (patch submitted by Andy Skelton)
1.1.1
  • Fixed bug with rendering issues fix in IE 5.5
  • Fixed bug with endCrop callback issues once cropper had been removed & reset in IE
1.1.0
  • Fixed bug with IE constantly trying to reload select area background image
  • Applied more robust fix to Safari & IE rendering issues
  • Added method to reset parameters - useful for when dynamically changing img the cropper is attached to
  • Added method to remove cropper from image
1.0.0
  • Initial verison

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

Screen shot of cropper in action

  • 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:

HTML:
  1. <script type="text/javascript" src="scripts/cropper/lib/prototype.js" language="javascript"></script>
  2. <script type="text/javascript" src="scripts/cropper/lib/scriptaculous.js?load=effects,builder,dragdrop" language="javascript"></script>
  3. <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:

JavaScript:
  1. function onEndCrop( coords, dimensions ) {
  2.     $( 'x1' ).value = coords.x1;
  3.     $( 'y1' ).value = coords.y1;
  4.     $( 'x2' ).value = coords.x2;
  5.     $( 'y2' ).value = coords.y2;
  6.     $( 'width' ).value = dimensions.width;
  7.     $( 'height' ).value = dimensions.height;
  8. }

Basic interface

This basic example will attach the cropper UI to the test image and return crop results to the provided callback function.

HTML:
  1. <img src="test.jpg" alt="Test image" id="testImage" width="500" height="333" />
  2.  
  3.     <script type="text/javascript" language="javascript">
  4.     Event.observe( window, 'load', function() {
  5.         new Cropper.Img(
  6.             'testImage',
  7.             { onEndCrop: onEndCrop }
  8.         );
  9.     } );
  10. </script>

Minimum dimensions

You can apply minimum dimensions to a single axis or both, this example applies minimum dimensions to both axis.

HTML:
  1. <img src="test.jpg" alt="Test image" id="testImage" width="500" height="333" />
  2.  
  3. <script type="text/javascript" language="javascript">
  4.     Event.observe( window, 'load', function() {
  5.         new Cropper.Img(
  6.             'testImage',
  7.             {
  8.                 minWidth: 220,
  9.                 minHeight: 120,
  10.                 onEndCrop: onEndCrop
  11.             }
  12.         );
  13.     } );
  14. </script>

Select area ratio

You can apply a ratio to the selection area, this example applies a 4:3 ratio to the select area.

HTML:
  1. <img src="test.jpg" alt="Test image" id="testImage" width="500" height="333" />
  2.  
  3. <script type="text/javascript" language="javascript">
  4.     Event.observe( window, 'load', function() {
  5.         new Cropper.Img(
  6.             'testImage',
  7.             {
  8.                 ratioDim: {
  9.                     x: 220,
  10.                     y: 165
  11.                 },
  12.                 displayOnInit: true,
  13.                 onEndCrop: onEndCrop
  14.             }
  15.         );
  16.     } );
  17. </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.

HTML:
  1. <img src="test.jpg" alt="Test image" id="testImage" width="500" height="333" />
  2. <div id="previewWrap"></div>
  3.  
  4. <script type="text/javascript" language="javascript">
  5.     Event.observe( window, 'load', function() {
  6.         new Cropper.ImgWithPreview(
  7.             'testImage',
  8.             {
  9.                 previewWrap: 'previewWrap',
  10.                 minWidth: 120,
  11.                 minHeight: 120,
  12.                 ratioDim: { x: 200, y: 120 },
  13.                 onEndCrop: onEndCrop
  14.             }
  15.         );
  16.     } );
  17. </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.

Discussion

Note: Please only use the comments for general comments and the discussion list to discuss this code project (e.g. implementation queries, change suggestions etc.).

Comments

There have been 750 comments so far, join the discussion.

Pages: « 1 2 3 4 5 [6] 7 8 9 10 1115 » Show All

251. Dave Bolton - 8th Jun 2007 - 7:30 pm

Hey Russ. Thanks for the response. I wasn’t clear enough, but I actually do exactly the same thing. I use a smaller working copy, and calculate the ratio.

minWidth and minHeight actually DO work fine… BUT if my final crop size is 100×100 (after applying ratio), and my working image is a ratio of 5 times smaller, then the minWidth and minHeight are only 20px, which is perfect for the actual crop box on the working image, but not perfect for the preview size.

e.g.
Original: 1000×1000, Min crop on original: 100×100
Working Image: 250×250, Min. crop on working image: 25×25 (maintains ratio)
leads to => Preview size: 25×25

So I’m happy with the way minWidth and minHeight work, I’m happy with using a working image so I’m not cropping an enormous image file, I’m just trying to find a way to have a reasonable size preview (say 100×100 in example). I realise this could mean a bit of pixelation in the previewWrap, but I’m okay with that.

252. zhangliang - 11th Jun 2007 - 4:41 am

very good demo,thank you very much,but i meet a question,i want to use your demo in asp.net ,but when i put the demo code into .aspx pages,it always tip “Envent,undifine” i used your js files,but i can’t compile through

253. zhangliang - 11th Jun 2007 - 5:11 am

no problem ,i lose the cropper.js file,i make a mistake,sorry,very thank you

254. Max Raskin - 13th Jun 2007 - 11:13 am

Well done, it’s a really useful tool, great idea using 4 surrounding divs to mimic overlay, great coding.

Only one thing, I noticed a bug, when a body’s CSS direction selector set to rtl, the select rectangle gets whacky, the solution to this problem is to force the container of the crop tool to have direction: ltr; set, works great that way.

cheers, Max.

255. dimitri - 15th Jun 2007 - 8:11 pm

awesome code!!

I have a simple question. How do you create that transparency effect? For example, lets say I have an image in a div, and I put an absolute div ontop of it, how do you black out the rest of the image and only keep the full opacity of the nested div?

Do you have to calculate it on the fly? Or do you layer 2 images or something?

256. Don Schonknecht - 16th Jun 2007 - 6:01 am

Very useful! One problem though – Konqueror doesn’t handle transparency and without transparency the image isn’t visible at all. A simple fix for this is to change the CSS to use a transparent tinted PNG in the presence of Konq/KHTML. You can also make the transparent PNG @ http://apps.everamber.com/alpha/ to save yourself sometime. :)

257. Nice Demo - 20th Jun 2007 - 10:15 am

Good work !!!!

258. shovavnik - 20th Jun 2007 - 1:51 pm

I’ve been working with cropper on a multi-lingual site that supports bidirectional layouts. In other words, some languages display from left to right and others from right to left.

Cropper has a problem on right to left pages where it draws the “west” overlay over the “east” overlay. You can see a demonstration of this problem if you go to to your castle demo and simply add style attribute to your body tag. Set it to style=”direction: rtl;” and watch the overlays.

I’ve solved the problem, but I’m not 100% sure it’s the correct solution.

In the drawArea() function, I’ve added the line
_4b.left=0;
after the line
_4b.height=_453;

So now _4b reads like this:
var _4b=this.west.style;
_4b.top=_451;
_4b.height=_453;
_4b.left=0;
_4b.width=_450;

It works in IE 7 and FF (most recent) in rtl and ltr. I haven’t checked other browsers.

259. Rupert - 26th Jun 2007 - 2:17 pm

Hi!

Your code is working well with one exception:

When I put an upload form and a dynamic crop preview into the same window, IE7 does not support the code and won’t open the file upload browsee window.

Does anyone know what it is about?

Thx

Rupert

260. Niklas Johansson - 2nd Jul 2007 - 8:25 pm

Is it possible to use imgPreview and onloadCoords at the same time? I doesent get it to work..

Thanks for a nice tool!!
Niklas

261. greg - 3rd Jul 2007 - 12:08 am

Hi Dave,

Been enjoying the cropper script for a while now, until recently where someone decided to try and use my stuff with IE7. All simple tests seemed to go smooth, but I keep on bumping into a strange problem now, where the drawArea function can’t be executed, because the areaWidth can’t be properly calculated, because in turn, this.img.width yields a value of 0. By adding a couple of alert()s here in there, the width can in some cases be “retrieved”. It seems as if, when moving the original img element inside the generated wrapper element, the image was reloaded by IE. That’s my only clue, because it is vaguely possible that this specific loading might be somewhat slow-ish. Removing the alert()s or move them around randomly re-causes the problem. Whatever the case, img.complete always returned true, which seem to contradict my suspicions… but then again, I’d never heard of .complete before, and am a bit doubtful about the two last line of the initialize method: I expected that only leaving the else clause’s content would still be working, maybe slightly slower, but it just doesn’t ?

If you had any ideas I could follow, I’d try some more debugging, but it’s pretty much a pita with IE, some I’ll give up at least for tonight.

262. greg - 4th Jul 2007 - 1:20 am

Well, my guesses turned out completely wrong, and I was under the influence of a badly formed table (yuk) with an unexpected table-layout:fixed… works like a charm now. sorry for the noise.

263. Kalyan - 4th Jul 2007 - 6:03 am

excellent library.thank you.

264. Michael Alahverdian - 4th Jul 2007 - 7:11 pm

This is one beautiful piece of script. I was looking for the functionality to then save the thumbnail as a separate file, any thing I missed with that, or just not implemented yet?

265. ste - 5th Jul 2007 - 1:06 pm

Found a bug, where by if you try and crop an image which is already smaller than the minimum size, the resize option would not display the image.

Changing and adding the following fixed the problem in resize_image.php

if($cropWidth

266. ste - 5th Jul 2007 - 1:08 pm

if($cropWidth < = 0) { $cropWidth = $imageWidth; }

if($cropHeight <= 0) { $cropHeight = $imageHeight; }
if($cropX < 0) $cropX = 0;
if($cropY < 0) $cropY = 0;

267. Frank - 6th Jul 2007 - 3:59 am

Nice JS, Dave.
I’m just wondering how easy to change your library to support multiple crop areas on one single image.

Conceptually, I think I need change selArea property on Cropper.Img object to an array of selArea, and a activeArea to reference to the currently selected selArea. When a new drag action is taken, add current selArea if any to the selArea array, create a new selArea and point activeArea to the new selArea. A new style needs to be added for the deactivated selAreas

Is that right? I’m not a JS expert, could you point the direction to me?

Thanks

268. greg - 6th Jul 2007 - 9:55 am

@Frank : out of the blue and not having tried myself, my first guess would be not to patch this script but rather keep an array of Cropper.Img instances in yours.

269. Frank - 9th Jul 2007 - 1:43 am

@greg , is Cropper.Img the whole image to crop or the the cropped area for the whole image? I thought it should be the whole image since it takes the whole image’s id as one the its constructor parameters. But the Cropper.Img.selArea is the cropped area. Am I right?

270. Ben - 9th Jul 2007 - 8:57 pm

A nice simple feature would be to have a “bull’s eye” or something of the sort that is centered in the crop area. Something like when you’re cropping in photoshop.

Thanks.

271. Matt - 11th Jul 2007 - 8:54 pm

This script works well in firefox, but in IE6 and IE7 it does not load the thumbnail correctly to crop. So instead it loads a black jpg for the thumbnail. Has anyone else had this situation?

272. Cime - 24th Jul 2007 - 12:28 am

Anybody got this to work on top of Google Maps?

273. jurciks - 25th Jul 2007 - 10:20 am

has anyone similar script that uses jquery?

274. Westy - 27th Jul 2007 - 7:19 am

I love this tool, but was wondering if you plan to update it so that it will work with the latest prototype/scriptaculous releases? The cropper doesn’t seem to work with prototype 1.5.1 and scriptaculous v1.7.1_beta3.

275. p palmer - 30th Jul 2007 - 5:26 pm

I second that, it would be great to have an update with
prototype 1.5.1.1 and scriptaculous v1.7.1_beta3, which dont currently work with cropper.

276. Dave - 30th Jul 2007 - 7:45 pm

I tried the cropper earlier today with the latest stable version of script.aculo.us (1.7.0) and prototype that comes with it (1.5.0) and the only change I had to make to get the tests working was include the effects module of script.aculo.us.

277. wozzzzza - 30th Jul 2007 - 11:16 pm

so dave, you got the code you can share with us how you added this effects module?? be good to get that.

278. Westy - 31st Jul 2007 - 6:38 am

I think Dave means he just had to include the effects.js scriptaculous file – rather than just calling src=”../lib/scriptaculous.js?load=builder,dragdrop” he added the effects.js also.

I was able to get it working just fine on the latest release (prototype 1.5.1 and scriptaculous v1.7.1_beta3)... I had a bug in my code. I did run into some problems on Safari though.

Maybe someone can help me:
Due to the way my cropper is getting created (returned from an Ajax call) I decided to just call new Cropper.Img(...); rather than using the Event.observe(...); method as used in the examples. This seemed to work just fine in all browsers except in Safari. Any ideas? I have instead had to create the function myself and call it directly

beginCropper = function(){
new Cropper.Img(...); and then wrote an onclick method to activate the beginCropper method. Any ideas how to get around this limitation? Am I doing something wrong? I can’t seem to use the Event.observer() method and get the cropper to instantiate when being returned from an Ajax call (meaning the JS is returned from the Ajax call and I’m evaluating with the evalScripts: true attribute in the the Ajax.Updater() method. Thanks, and sorry for the confusion earlier… very nice tool Dave!

279. bjhoern - 2nd Aug 2007 - 3:50 pm

Hello,
I have a problem with it: I’m using the package from above, that means prototype 1.5 and scriptalicious 1.6 or sth like that …
everythings working fine except showing the preview of the cropped image. I’m displaying the image that has to be cropped via

Is this the problem? I cannot use since the image is in an htaccess protected directory and so I have to read it out via a PHP script, that sends also the right image header … so it shouldn’t be the problem but I dunno …

My whole code:

// setup the callback function
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() {
new Cropper.Img(
‘testImage’,
{
displayOnInit: true,
previewWrap: ‘previewWrap’,
minWidth: 120,

minHeight: 120,
ratioDim: { x: 120, y: 120 },
onEndCrop: onEndCrop
}
);
} );

280. Luke Goodere - 2nd Aug 2007 - 9:02 pm

Hi, your script is very close to what IM looking for, with a slight modification, is it possible to use your crop preview window to move the image about?

I want users to upload images, which will then be created into thumbnails of a set size. I’d love to use your preview window so they can for example center it on their faces, can this be done only using the crop preview window?

Thanks, Luke

281. lora - 3rd Aug 2007 - 11:56 am

Q: how to implement zoom for example 2x, 3x on the preview image?

great work!!!

282. abc - 3rd Aug 2007 - 1:20 pm

i am using cropper.js with ajax form. after submition of form it gives me error like
$(“x1”) has no properties
onEndCrop(Object x1=150 y1=107×2=350 y2=227, Object width=200 height=120)prototype.js (line 182)
endCrop()cropper.js (line 535)
bindAsEventListener(mouseup clientX=0, clientY=0)prototype.js (line 55)
[Break on this error] escapeHTML: function() {

i m not getting where i m going wrong

283. Jamie - 3rd Aug 2007 - 3:10 pm

Hello,
I just have a quick question – I seen this application being used by another site so I figured I would look into where it came from – I seen it being used for http://www.bandzoogle.com

Anyways – what my question is – and I downloaded and played around with the demo – forced a static size and moved it around etc –

What my question is – how do you spit out the results of the croped image to a new file? in none of the preview example pages do I see where it spits it out. Is this something I have to program in myself – I use Cold Fusion – does anyone have some ready made code that will spit out the selected croped image?/

Thanks very much for your consideration – and again very cool!

Jamie

284. Westy - 6th Aug 2007 - 5:48 am

Hello Jamie,

Yes, you’ll need to do the cropping on the application server. I also use CF and I use Efflaire’s CFX_ImageCR3 which is an amazing CFX tag and located at http://efflare.com/ It is really fast and offers amazing quality and will do pretty much anything you want it to do.

It makes image manipulation really easy. So, just assign the values returned from cropper (which are set to hidden form variables) and post to your page which will crop the image. CFX_ImageCR3 makes is really easy to crop. Hostmysite.com offers this CFX tag as part of its ColdFusion hosting plan, but I believe CF8 will offer image manipulation natively.

Hope this helps,

Westy

285. Jamie - 6th Aug 2007 - 4:09 pm

Hello!
Thanks very much – Do you happen to have a Free Download link of the Full version – Just to try it of course!

286. Westy - 6th Aug 2007 - 11:55 pm

Sorry, I don’t. But I can say with utmost confidence that it is simple to use and one of the best image manipulation tools around.

287. prerna - 7th Aug 2007 - 10:12 am

javascript function gets called thrice on “onClick” event of a Button. Only if I click the unselected area of a button. If I click any where in the selected area of Button the function is working fine, it gets exected only once.

288. Nima - 8th Aug 2007 - 12:12 pm

Please someone help.. :)

I want to use this image cropper, but my language is Asp. But I am newbie, and It will take a long time to understand it. if someone could help me with the backend code for doing the cropping?
you can write to me at. biip19@hotmail.com

289. Dirk - 9th Aug 2007 - 7:37 am

Nice tool, it works fine in an standard HTML or ASP.NET aspx Site.
I’ve a problem, when the page is ajax-supportet. After I update a part of the site, the image visible or image-URL for example, with an ajax HTMLRequest, you can’t select the image to set the cropperframe or can do anything else with the image.
As workaroung, i’ll be send a postback and refresh the complete-site. But this is not what I want on an regular ajax-supported page. ;-)

Have someone a tip?

290. Dirk - 9th Aug 2007 - 10:39 am

Sorry, I’ve forgot an eMail-Adress for an answer: dbar.master@googlemail.com

Nice tool, it works fine in an standard HTML or ASP.NET aspx Site.
I’ve a problem, when the page is ajax-supportet. After I update a part of the site, the image visible or image-URL for example, with an ajax HTMLRequest, you can’t select the image to set the cropperframe or can do anything else with the image.
As workaroung, i’ll be send a postback and refresh the complete-site. But this is not what I want on an regular ajax-supported page. ;-)

Have someone a tip?

291. Will - 10th Aug 2007 - 4:16 pm

I found a bug with the cropper that happens when ratioDim and minWidth and minHeight are set, and the user holds down the shift key while resizing. Once the crop area gets to the minimum size (while obeying the ratio) it will start to resize down to a square.

Here is the fix:

Line 799 of cropper.uncompressed.js should change from:
if( (mins0 != 0 || mins1 != 0) && square ) {

to

if( (mins0 != 0 || mins1 != 0) && square && this.ratioX 0 ) {

Line 296 of cropper.js needs to be changed from:

if((_27<sup><a href="#fn0">0</a></sup>!=0||_27<sup><a href="#fn1">1</a></sup>!=0)&&_22){

to

if((_27<sup><a href="#fn0">0</a></sup>!=0||_27<sup><a href="#fn1">1</a></sup>!=0)&&_22&&this.ratioX0){

Thanks for the wonderful tool!

292. Will - 10th Aug 2007 - 4:20 pm

Well, textile appears to love JS. Here is my last post again:

I found a bug with the cropper that happens when ratioDim and minWidth and minHeight are set, and the user holds down the shift key while resizing. Once the crop area gets to the minimum size (while obeying the ratio) it will start to resize down to a square.

Here is the fix:

Line 799 of cropper.uncompressed.js should change from:

JavaScript:

  1. if( (mins[0] != 0 || mins[1] != 0) && square ) {

to

JavaScript:

  1. if( (mins[0] != 0 || mins[1] != 0) && square && this.ratioX <span style="color: #CC0000;color:#800000;">0</span> <span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> </div></li></ol></div>
    </div></div><br />

Line 296 of cropper.js needs to be changed from:

<div class="igBar"><span id="ljavascript-9"><a href="#" onclick="javascript:showPlainTxt('javascript-9'); return false;">Display code as plain text</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-9">
<div class="javascript"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">(</span>_27<span style="color: #66cc66;">[</span><span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">]</span>!=<span style="color: #CC0000;color:#800000;">0</span>||_27<span style="color: #66cc66;">[</span><span style="color: #CC0000;color:#800000;">1</span><span style="color: #66cc66;">]</span>!=<span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">)</span>&amp;&amp;_22<span style="color: #66cc66;">)</span><span style="color: #66cc66;">{</span> </div></li></ol></div>
</div></div><br />

to

<div class="igBar"><span id="ljavascript-10"><a href="#" onclick="javascript:showPlainTxt('javascript-10'); return false;">Display code as plain text</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-10">
<div class="javascript"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">(</span>_27<span style="color: #66cc66;">[</span><span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">]</span>!=<span style="color: #CC0000;color:#800000;">0</span>||_27<span style="color: #66cc66;">[</span><span style="color: #CC0000;color:#800000;">1</span><span style="color: #66cc66;">]</span>!=<span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">)</span>&amp;&amp;_22&amp;&amp;this.<span style="color: #006600;">ratioX</span>0){

Thanks for the wonderful tool!

293. Dave - 10th Aug 2007 - 8:05 pm

Hi Will,

Thanks for the bug fix, I’ve added it to the list of changes to implement in the next version, also I have no idea what is going on with textile.

-D

294. Nima - 13th Aug 2007 - 10:57 am

Hi everybody

I have issue, if someone could help. when I upload a picture I can only see the picture in the small Preview window but the big picture is black? I am using Asp.

could someone help – if you could write to my Email: biip19@hotmail.com

295. fru - 13th Aug 2007 - 2:55 pm

Hello,

Nice job !

could you please provide a code for selecting a square, but when you change the selection it grow from the center and no from the corner.

Sorry for my bad english !

296. Kev - 14th Aug 2007 - 10:23 am

Great work! Great tool! Thanks alot!

But is this a bug? The onEndCrop handler is being called whenever I click anywhere on the screen, or use the browser window’s scroll bar. I thought maybe something wrong with my implementation but this behaviour is the same on the demo on this site.

Can anyone suggest a fix/workaround?

297. Soth ratana - 17th Aug 2007 - 4:48 am

Dear friend

i show your script is so beautiful…
i like it
But it’s not i want …
Can u do like that

1-crop/resize/compress image with javascritp only (without call server script working only Javascript)

it mean :if user have big image file…it will process in client before send file to server..so that file is smaller than orginal

298. Dave - 17th Aug 2007 - 8:39 am

Soth:

It is not possible to manipulate images in this way using just JavaScript, this script is the front end which allows you to select an area for cropper you then have to pass this to a server side script to perform the cropping etc.

299. Saurabh - 22nd Aug 2007 - 3:12 pm

I saw your script being used on a site called http://www.webwag.com/. instead of cropping a picture they are cropping the whole website. can you give me some idea of how they are able to do so ??

300. Dave - 23rd Aug 2007 - 6:18 pm

Saurabh:
I couldn’t see where you were referring to on their site, but my guess is that they have some server side stuff that takes a screen shot of a site (there’s plenty of people who are doing that) and then using the cropper on that image.

Pages:« 1 2 3 4 5 [6] 7 8 9 10 1115 » Show All

Leave a comment

No HTML please, only textile. For code please use [lang]...[/lang] tags (e.g. [html]...[/html] for HTML)