crop1This is a featured page


Crop tab

The crop tab lets you specify full automatic cropping, full manual cropping and a range of options between. Note that VueScan also lets you change these values by using the mouse on the preview image. The crop area is displayed as a blinking dashed line (marching ants) that defines the area for subsequent VueScan operations. Position the mouse over the blinking line and drag to reposition any edge. Hold down the shift key and click and drag anywhere within the crop area to reposition the entire crop area (or drag the center of the crop area with the mouse). Click the scan tab for VueScan to display the result of the cropping automatically. The scan tab will use the data from the preview if a full scan has not yet been performed. The area included in the crop is important in two ways. First, this is the area of the scan that will be included in the output files. Second, this area is used to calculate color balance, histogram, and other settings. Be sure not to include the border around the edge of an image as part of the crop as this may cause these settings to be calculated incorrectly. Crop | Buffer (%) can also be used to prevent inadvertent inclusion of data outside of the desired frame in color settings.) Crop | Crop size
Crop | X/Y size
Crop | Auto offset
Crop | X/Y offset
Crop | Multi crop
Crop | Multi type
Crop | X/Y images
Crop | X/Y spacing
Crop | X/Y padding
Crop | X/Y linked
Crop | Show multi outline
Crop | Auto rotate
Crop | Crop orientation
Crop | Lock aspect ratio
Crop | Aspect ratio
Crop | Border (%)
Crop | Buffer (%)
Crop | Preview area
Crop | Preview X/Y offset/size
Crop | Focus X/Y offset

Crop | Crop size

This option specifies the method used to determine the size of the cropped image: Manual Lets you enter all of the crop sizes manually. This option will also be selected if you have adjusted the crop size or position using the mouse on the preview window. Auto Analyzes the image and uses built-in rules to find the edges automatically. This setting works well most of the time if you want to capture the whole image. Maximum Sets the crop size to be the same as the size of Crop | Preview area. This is particularly useful when saving the raw scan data to files as it ensures that everything the scanner reads will be saved. (specific sizes) Sets the crop area to known dimensions. If a specific size is selected, the Crop | Crop orientation option will be available. Basic Option: This option is always displayed.

Crop | X/Y size

This is the size of the image area that you are cropping. If set to zero, the entire scanned area will be used. Basic Option: This option is displayed when Crop | Crop size is set to "Manual".

Crop | Auto offset

Setting this option will automatically offset the crop box. It will find the best placement for it to capture as much of the image as possible. To save time when batch scanning, clear this option and Crop | Auto rotate and set Input | Lock exposure. Then when you press "Scan" it will perform a scan without additionally creating a preview. Advanced Option: This option is displayed when Crop | Crop size is set to anything except "Maximum".

Crop | X/Y offset

This is the offset in the preview area of the start of the image data. These positions are relative to the upper left-hand corner of the preview area. See Crop | Preview area. Basic Option: This option is displayed when Crop | Auto offset is displayed and not set.

Crop | Multi crop

This option is used with some flatbed scanners that have a black plastic mask that holds multiple slides or film strips. It can also be used to scan multiple snapshots on a flatbed scanner when you put them in a grid on the flatbed. This option indirectly sets up the Crop | X/Y images, Crop | X/Y spacing, Crop | X/Y padding, and Crop | X/Y linked options. If you have a film holder that isn't supported by VueScan, use the "Custom" option. When you find the values that work best with your film holder, please send these values to support@hamrick.com (make sure you put the word VueScan in the body of the e-mail, or it won't get through). Basic Option: This option is always displayed.

Crop | Multi type

Set this option to control what type of image is being cropped in each section of the custom multi crop area. Advanced Option: This option is displayed when Crop | Multi crop is set to "Custom".

Crop | X/Y images

Set these options to set up a grid for scanning separate images. Each image within the grid can be cropped and rotated independently. Advanced Option: This option is displayed when Crop | Multi crop is set to "Custom".

Crop | X/Y spacing

These values can be set when Crop | X/Y images is set to a value greater than 1. See Crop | X/Y images. Set the approximate width (X spacing) and height (Y spacing) of each element in the grid defined by Crop | X/Y images. For example, 8 4x6 photos on a 12x16 flatbed scanner would have X spacing of 6 inches and Y spacing of 4 inches. Advanced Option: This option is displayed when Crop | Multi crop is set to "Custom".

Crop | X/Y padding

If these values are set to 0, then the grid is centered, otherwise this is an offset to the first box in the grid. Advanced Option: This option is displayed when Crop | Multi crop is set to "Custom".

Crop | X/Y linked

This option indicates that all frames in the horizontal or vertical direction move together when one of the frames is offset. This usually indicates strip film in a horizontal or vertical orientation. Advanced Option: This option is displayed when Crop | Multi crop is set to "Custom".

Crop | Show multi outline

Turn this option off if you don't want to see the lines around the multi-crop boxes. Advanced Option: This option is displayed when Crop | Multi crop is used.

Crop | Auto rotate

Setting this option will automatically rotate the crop box. It will find the best placement for it to capture as much of the image as possible. This option only functions when the crop box fits inside the preview area both horizonally and vertically. Some slide scanners let you put the slide in landscape or portrait mode, and this option rotates the image to either portrait or landscape orientation to match the image. To save time when batch scanning, clear this option and Crop | Auto rotate and set Input | Lock exposure. Then when you press "Scan" it will perform a scan without additionally creating a preview. Basic Option: This option is displayed when Crop | Crop size is set to anything except "Maximum" and when Crop | Multi crop isn't used.

Crop | Crop orientation

Use this option to control whether the size specified in the Crop | Crop size option is oriented in portrait or landscape view. Basic Option: This option is displayed when Crop | Crop size is set to a specific size and not auto rotating, or when Crop | Crop size is set to "Auto" and Crop | Multi crop isn't used.

Crop | Lock aspect ratio

This option forces the crop box to keep a constant aspect ratio while one (or two) edges are being dragged by the mouse. This ratio is always greater than one, and is the ratio of the longest edge to the shortest edge of the crop box. If set to "Off", the aspect ratio isn't locked. If set to "Image size", the aspect ratio is computed using the Output | Printed size option. If set to "Manual", the Crop | Aspect ratio option will appear and you can manually set the aspect ratio of the crop box. Advanced Option: This option is always displayed.

Crop | Aspect ratio

If Crop | Lock aspect ratio is set to "Manual", use this option to manually set the ratio of the longest edge to the shortest edge of the crop box. For instance, if you plan on printing an image on 4x6 paper, the aspect ratio should be 1.5 (6 divided by 4). Advanced Option: This option is displayed when Crop | Lock aspect ratio is set to "Manual".

Crop | Border (%)

This instructs VueScan to enlarge the image beyond the edge of the crop box. This added border is ignored when computing the color balance of the image. This option is useful for adjusting the size or position of the crop box that may have cut off parts of the image you want to keep. Because border will extend the effective area that is cropped, it will tend to include areas of white (or black) in the resulting image; if these parts of the image were not ignored when computing color balance, they could skew the results. Border is a percentage relative to the dimensions of the cropped area, up to the maximum size of the preview area. Border can also be set as a negative value in order to reduce the size of the image. Compare this option to Crop | Buffer (%). Advanced Option: This option is always displayed.

Crop | Buffer (%)

This causes VueScan to ignore some image data just inside the edge of the crop box of the image when computing the color balance of the image. Unlike Crop | Border (%), the buffer does not affect the size of the image. This option is useful to account for sizing or positioning errors of the crop box that incorrectly include parts of the image from its outer edges. These white or black areas can significantly skew the calculation of color balance if not ignored. Buffer is a percentage relative to the dimensions of the image area. Because it includes a Crop | Border (%) it should always be set slightly higher than Border. Compare this option to Crop | Border (%). Advanced Option: This option is always displayed.

Crop | Preview area

The preview area is the subset of the total scan area that gets scanned to produce a preview. This option can be set manually, set to the same as the last preview, set to the crop box, set to the default or set to the maximum possible. Note: if you set a smaller preview area, the scanner head will move only far enough to cover that area. This can reduce the amount of time needed to scan, especially on flatbed scanners. Because the stepper motor that moves the scan head is often the factor that limits speed, it also makes sense to orient images in landscape (and set the preview area accordingly). Advanced Option: This option is always displayed.

Crop | Preview X/Y offset/size

These options describe the size of the preview area. They are relative to the upper left-hand corner of the image, negative, or slide. Advanced Option: This option is displayed when Crop | Preview area isn't set to "Maximum".

Crop | Focus X/Y offset

This option determines where the auto focus is centered. This position is displayed on the preview as a small animated box. Film tends to curl along its length, as well as across its width in which case the focus will be slightly off as the edges of the film will be closer to the lens than the center. To minimize this effect, position the focus point between the center of the film and its edge in both dimensions, or slightly closer to the edge to account for less depth-of-field the closer to the lens. Advanced Option: This option is displayed when the scanner is capable of focusing.




http://www.pegasusimaging.com/prizmgrayfeatures.htm
Prizm® Gray Application

Grayscale Image Processing
left Overview Features Benefits Download right

Features
Expand All

Expand/CollapseTechnical Notes
  • Operating environments: Windows XP, 2000 or above
  • Customer-acclaimed technical support
  • Free trial version available upon request
Expand/CollapseBatch Processing
  • Supports high-volume scanning operations and service bureaus requiring multiple image processing steps
  • Apply multiple image enhancement processes in a single run
Expand/CollapseJob Manager
  • Main processing application for enhancing images
  • Deskew, crop, resize and threshold grayscale and color images
  • Create reusable enhancement lists and job profiles specific to projects or document types
  • Define all image processing settings, including Confidence Values
  • Specify input and output file locations and formats
  • Automatically routes low confidence images to Exception Handler application for manual processing
Expand/CollapseException Handler
  • Manually correct "exception" images through an easy-to-use interface
  • Once processed, the image can be "accepted" by the operator, and saved to the output folder
Expand/CollapseDeskew
  • Straighten skewed grayscale and color images meeting a minimum confidence value to find over-skewed images or route to the Prizm Gray Exception Handler for operator correction

    DESKEW

    Grayscale image deskew
Expand/CollapseIntelligent Crop
  1. Automatically remove dark borders frequently created when scanning film
  2. Confidence values allow routing of exception images (images with low contrast or edges that are not sharp and straight) to another cropping method or to an operator correction station for exception handling
  3. Rectangle Crop with Confidence Values
    • Crop and rotate an image so the resulting output image is cropped to the edges of the original document
    • Looks for contrast in hue, saturation or brightness between the background color and the edge

      RECTANGLE DETECT

      Image crop, rectangle detection


  4. Border Detection with Confidence Values
    • Find the edges of a scanned document by automatically comparing the document to a specific background border color
    • Configurable speck size detection accounts for white noise resulting from poor quality film

      BORDER DETECT

      Image crop, border detection


  5. Data Detection with Confidence Values
    • Crop an image to the first occurrence of image content
    • Looks for contrast in hue, saturation or brightness between the background color and the image data, with a minimum speck size set that should allow for variance in the border color

      DATA DETECT

      Image crop, data detection
Expand/CollapseImage Formats Supported
  1. Input grayscale or color
    • TIFF, JPEG, Windows BMP, JFIF, PCX
  2. Output bitonal, grayscale, or color
    • TIFF (Group 3 1-D & 2-D, Group 4, Uncompressed, Pack Bits), JPEG, BMP, CALS1, PCX
Expand/CollapseBrightness, Contrast, Gamma
  • Brightness/Contrast and Gamma Correction improve image quality and readability
  • Enhance the text or other image content by lightening or darkening

    BRIGHTNESS / CONTRAST

    Brightness / contrast

Expand/CollapseResize
  • Use Pixel Size method of resizing by entering the width and height in pixels of the output image
  • Use Aspect Ratio parameter by entering one of the two values, and calculating the second value
Expand/CollapseThresholding
  1. Convert a continuous tone (grayscale or color) image to a black and white (bitonal) image
  2. Allow the end user to select from three methods of thresholding using configurable settings:
    • Localized
    • Automatic
    • Manual

Expand/CollapseAlso Available
Prizm® Viewer v7 The Browser-Based Image Viewer
FolderBots™ The Image Transformer Service
ScanFix® Application v4 Bitonal Image Enhancement Application
Prizm® IP Advanced Image Processing Toolkit



Sitemap | © 2008 Pegasus Imaging Corporation. All Rights Reserved. | Privacy Statement.





http://docs.gimp.org/en/gimp-tool-crop.html

4.4. Crop

Revision History
Revision $Revision: 2532 $ 2008-01-11 j.h
Figure13.99. Crop tool
Crop tool

The Crop Tool is used to crop or clip an image. It works on all the layers of the image, visible and invisible. This tool is often used to remove borders, or to eliminate unwanted areas to provide you with a more focused working area. It is also useful if you need a specific image size that does not match the original dimensions of your image. Just like the selection tools, the new crop tool has been enhanced with the v2.4 release. The resize handles actually resize the crop rectangle instead of providing both resize and move functionality. The tool behaves more naturally and consistently with other GIMP tools. To move, simply drag the rectangle clicking within the area. Resizing is possible in one or two axes at the same time dragging the handle-bars on the sides and corners. The outside area can be darkened with a nice passepartout effect to better get the idea of how the final crop will look like. To validate cropping, click inside the crop rectangle or press the Enter key. When the mouse becomes the moving cross-hair, you can use the keyboard arrow keys to move the crop rectangle. Holding the Shift key down allows to move by steps of 25 pixels. You can use Guides to position the crop area. Make sure that the View → Snap to Guides option is checked.
4.4.1. Activate the Tool
  • You can access this tool from the image-menu through: Tools → Transform tools → Crop.
  • The Tool can also be called by clicking the tool icon: ,
  • or by using the Shift+C keys.
Tip
[Tip]
A different and quicker way to crop selections is using the Image → Crop Image function in the Image menu.
4.4.2. Key modifiers (Defaults)
Shortcut The Shift+C shortcut will change the active tool to the Crop Tool. Key modifiers When you maintain click on the crop rectangle, handles disappear and
  • holding down the Ctrl key toggles to the Extend from Center option,
  • holding down the Shift key toggles to the Fixed option, which makes some dimensions fixed.
4.4.3. Options
Figure13.100. “Crop” tool options
Crop tool options

Overview The available tool options for Crop can be accessed by double clicking the Crop tool icon. Current Layer Only This option will make crop affect only the active layer. Allow Growing This option allows the crop or resize to take place outside the image or layer boundary.
Figure13.101. Example for “Allow Growing”
Example for Allow Growing
The option is checked: you can draw the crop rectangle outside the image border.
Example for Allow Growing
The resulting image has the same size as the crop rectangle. The area outside the original image limit is transparent.

Expand from Center When this option is checked, the crop rectangle expands from the first pixel you clicked taken for center. You can toggle this option with Ctrl while drawing the crop rectangle. Fixed You can also access this option by holding down the Ctrl key while drawing the crop rectangle. This option offers you several to make drawing the crop rectangle respect fixed dimensions, or their ratio:
  • Aspect ratio: That's the default possibility. Width and Height keep the same ratio they have in the original image, when drawing the crop rectangle.
  • Width / Height: only Width or Height will remain fixed. The value of this dimension can be set in the text box below; it defaults to 100 pixels.
  • Size: both Width and Height will be fixed. Their values can be set in the text box below, in the form “150x100” for example. The crop rectangle will adopt this values as soon as you click the image. On the right, two buttons let you choose a Landscape (widthwise) or Portrait (upright) format for the crop rectangle.
Position These two text boxes show the position (horizontal on the left, vertical on the right) of the upper left corner of the crop rectangle in real time and you can change it manually too. It is stated in pixels, but you can change the unit thanks to the drop-down list of the px button. The coordinate origin is the upper left corner of the canvas (not of the image). Size These two text boxes show the size (horizontal on the left, vertical on the right) of the crop-rectangle in real time and you can change it manually too. It is stated in pixels, but you can change the unit thanks to the drop-down list of the px button. Highlight This option toggles the dark outside area intended for highlighting the crop rectangle. Guides All kinds of guides are described in Section2.2, “ Rectangle Selection ” Autoshrink The Auto Shrink button will attempt to locate a border, in the active layer, from which to draw dimensions from. This option only works well with isolated objects contrasting sharply with background.
Figure13.102. Example for “Autoshrink”
Example for Autoshrink
An image with a sharp limit in it and a crop rectangle.
Example for Autoshrink
After clicking the Autoshrink button, the crop rectangle has been shrunk to fit the sharp limits.

Shrink Merged This option works the same, with Auto Shrink or not. It uses the pixel information from all visible layers, rather than just from the active layer.


Photoshop Tutorials: Cropping Photos To Specific Frame Sizes

Learn Photoshop with Photoshop Tutorials at Photoshop Essentials.com

Written By Steve Patterson In this Adobe Photoshop tutorial, we're going to look at how to easily crop a photo to whatever frame size you need. A common question we receive has to do with resizing photos. Specifically, how do you resize a photo to a standard frame size like 5x7", 8x10" or 11x14" without distorting the photo and making everyone in it appear tall and thin or short and fat? Here's an example of the problem. I take many of my photos with a Canon Digital Rebel XT, which is an 8MP camera. Here's a photo I took with it last winter: Adobe Photoshop tutorial image.
Photoshop Tutorials: The original photo.
Download this tutorial as an easy to read, ready to print PDF eBook! Now, let's say I want to print this photo as an 8x10" so I can frame it. Since the photo was taken with an 8MP camera, getting a professional quality 8x10" print from it shouldn't be a problem. Let's look at the pixel dimensions of this image so we can see exactly what size it is. I'm going to open Photoshop's Image Size dialog box by going up to the Image menu at the top of the screen and choosing Image Size. If we look at the Pixel Dimensions section at the top of the dialog box, we can see that my photo, as it appears straight out of the camera, has a width of 3456 pixels and a height of 2304 pixels: Adobe Photoshop tutorial image.
Photoshop Tutorials: Photoshop's Image Size dialog box showing the pixel dimensions of the photo.
The Pixel Dimensions section tells us exactly how many pixels our image is made of, but it has nothing to do with the size the image will print. To view or change the photo's print size, we need to turn to the Document Size section of the dialog box. Currently, the Document Size section is telling us that at a resolution of 240 pixels per inch, which is a standard resolution for professional quality printing, my photo will print at a size of 14.4x9.6 inches. That's certainly a decent size photo, but I probably wouldn't have much luck finding a frame that fits it. If I want to print the image and frame it, I'll first need to resize it to a standard frame size, like 8x10". Let's see what happens when I try to change the print size of the photo to 8x10" using the Image Size dialog box, which is normally what we use when resizing images. Since my photo is in landscape mode (meaning the width is larger than the height), I'm actually going to want a 10x8" photo, so I'll change the Width value in the Document Size section to 10 inches. I want to make sure I don't distort the aspect ratio of the image when I resize it, so I'm going to select the Constrain Proportions option at the bottom of the dialog box, which tells Photoshop to change the height of the image automatically according to the new width value I've entered. I'll go ahead and change the Width to 10 inches: Adobe Photoshop tutorial image.
Photoshop Tutorials: Changing the print size of the image in the Document Size section.
I've now changed the width of my photo to 10 inches, and because I had the Constrain Proportions option selected, we can see above that Photoshop went ahead and changed the height of my photo to... 6.667 inches?? That's not right. We need a 10x8" photo, not 10x6.667". Hmm... I guess I'll just have to change the Height to 8 inches myself: Adobe Photoshop tutorial image.
Photoshop Tutorials: Changing the height of the image manually in the Document Size section.
Okay, there we go. I've changed the height of the photo to 8 inches, and now the Document Size section is telling me that my photo is going to print perfectly at.... 12x8"?! Hey, what's going on? All I want to do is change the print size to 10x8", but if I change the width value, the height is wrong, and if I change the height value, the width is wrong! How do I resize the photo to 10x8"? The answer is, you can't. At least, not by trying to resize the image with the Image Size dialog box. The original dimensions of the photo won't allow us to resize it to a 10x8" without distorting the look of the image, which we don't want to do. So what do we do then? Simple! We forget about the Image Size dialog box and instead, we crop the photo to the exact size we want! For that, we use Photoshop's Crop Tool!

Step 1: Select The Crop Tool

The first thing we need to do is select the Crop Tool, so either grab it from the Tools palette or press the letter C on your keyboard to select it with the shortcut: Adobe Photoshop tutorial image.
Photoshop Tutorials: Select the Crop Tool.

Step 2: Enter The Exact Print Dimensions You Need In The Options Bar

With the Crop Tool selected, if you look up in the Options Bar at the top of the screen, you'll see a Width and Height option where you can enter in the exact width and height you need, along with the type of measurement (inches, centimeters, pixels, etc). Since I want to crop my image to a 10x8", I'm going to enter 10 into the Width option, followed by a "in" which stands for "inches". Then I'll enter 8 into the Height option followed by another "in" for "inches": Adobe Photoshop tutorial image.
Photoshop Tutorials: Entering the exact width and height in the Options Bar.

Step 3: Drag Out A Cropping Border

Once you've entered the exact size you need, simply click inside your image and drag out a cropping border. The area inside the border is the part of the photo you'll be keeping, and everything outside the border (which appears darker) will be cropped away. You'll notice as you drag that the shape of your border is now fixed, and that's because we set the aspect ratio of the border when we entered the exact width and height we needed into the Options Bar. The only thing we can do is adjust the overall size of the border by dragging any of the four corner handles. You can also reposition the border inside the image by moving your cursor inside the border (it will change into a black arrow), then clicking and dragging the border around with your mouse: Adobe Photoshop tutorial image.
Photoshop Tutorials: Drag out a cropping border with the Crop Tool.

Step 4: Press Enter / Return To Crop The Image

When you're happy with the size and position of your cropping border, simply press Enter (Win) / Return (Mac) to have Photoshop crop the image: Adobe Photoshop tutorial image.
Photoshop Tutorials: Press Enter (Win) / Return (Mac) to crop the image.
And just like that, I've successfully cropped my image to a 10x8" without distorting it. If we go back to the Image Size dialog box once again by going up to the Image menu and choosing Image Size, we can see that sure enough, the Document Size section is now showing a width of 10 inches and a height of 8 inches: Adobe Photoshop tutorial image.
Photoshop Tutorials: The image will now print successfully at 10x8".
And there we have it! That's how easy it is to crop an image to any frame size you need in Photoshop!
http://www.nwhite.net/MooCrop/
MooCrop

About

MooCrop is an Image Cropping utility using the amazingly powerful mootools javascript framework. Alone it serves no practical purpose but used in conjuction with a server side script becomes a powerful image manipulation tool.

Why

Looking for a mootools solution, I searched and came up with a few existing implementations. Everything I came across were only partial implementations. Those that were more polished seemed to be sluggish and effecting the DOM needlessly in some places. I wanted a class that had a very intuitive interface and played nicely with the existing DOM and more importantly I wanted it to be fast. I came to the conclusion that developing my own would give me a better understanding of mootools and broaden my understanding of drag and drop inside the DOM. Initially I tried using the Drag.Base class found within mootools but found this to be clumbsy for this highly specialized form of dragging. With default options a single drag is moving/resizing not one but 13 DOM elements. The dragging functionality has been optimized with this sole purpose in mind.

Features

MooCrop goal is to do only one thing (image crop ) but to do it well. With this in mind I tried to make the class as flexiable as possible for your own use.
  • Completely customizable CSS styling
  • Detects and handles multiple CSS box models
  • Allows for masking to be toggled
  • Ability to hide resize handles during drag
  • Custom events for your own modification
  • Relative based postioning rather then absolute (should handle overflow properly)
  • Works and retains layouts on floating images.
  • Resize from 8 different directions
  • Ability to set minimium size limit
  • Cleans up nicely, leaving your DOM in its original state when removed.
  • Fast!

Documentation

Arguments element the image element you want to attach MooCrop to. options an object. see options below Options maskColor css valid color value for the mask background color. default: 'black' maskOpacity opacity value (0-1) for the masking areas. default: '.4' handleColor css valid color value for the handle background color. default: 'blue' handleWidth width of handles. default: '8px' handleHeight height of handles. default: '8px' cropBorder css valid border value for the crop area border. default: '1px dashed blue' min an object representing the minimum size the crop box can be. default: { 'width' : 50, 'height' : 50 } showMask a boolean flag to show or hide the masking area. default: true showHandles a boolean flag to show or hide handles during drag. default: false Methods getCropInfo returns an object with the current relative coordinates of the crop area in relation to the image top left corner. object properties ( 'width','height','top','left','right','bottom' ). removeOverlay detatches MooCrop from image and return the image to its pre MooCrop state. Events onBegin fired just before dragging or resizing occurs. returns [ image src, croparea, bounds, handle ] image src is the complete path of the image being cropped. croparea see getCropInfo(). bounds is a coordinates object defining the image bounds for the crop area, useful for labels ( see example below ). handle is the name of the current drag/resize event [NW,N,NE,E,SE,S,SW,W] if drag = NESW onCrop fired during drag. returns [ image src, croparea, bounds, handle ] onComplete fired after the drag or resize event. returns [ image src, croparea, bounds, handle ] onDblClk fired when the crop area is double clicked. returns [image src, croparea, bounds ] Additional Notes MooCrop does not rely on any css within the document its all set through object initialization. In preventing issues from arising from padding and margins the target image is hidden and a div is inject before it in the DOM tree. The image is used as a background image. The box is adjusted and the offset of the background image is based on the box model. If IE box model is being used and a border has been defined for the crop area the border will be included in the px width and height. The traditional box model will not include the border. When using MooCrop you must attach during or after the window load event. Using domready doesn't work because the image hasn't been rendered yet.

Requirements

MooCrop has been tested with IE 6 & 7, FF 2+, Opera 9.2 and Safari 2 & 3. Download mootools, required dependancies:
  • Core: Moo, Utility, Common
  • Native: Array, String, Function, Element, Event, Dom
  • Element: Element.Dimensions, Element.Events
  • Plugins: Hash
For your convenience:

Examples/Usage

Include mootools and MooCrop in your page header <script type="text/javascript" src="/mootools.js"></script>
<script type="text/javascript" src="/MooCrop.js"></script>
Default new MooCrop('crop_example1');
Changing the mask new MooCrop('crop_example2',{
'maskColor' : '#96743f',
'maskOpacity' : '.8'
});
Changing the handles new MooCrop('crop_example3',{
'handleColor' : '#333333',
'handleWidth' : '10px',
'handleHeight' : '10px',
'showHandles' : true
});
Adding labels with events var crop4 = new MooCrop('crop_example4');

// create a container for a label
// wrapper is the container that all
//MooCrop operations are performed
var indicator = new Element('span',{
'styles' : {
'position' : 'absolute',
'display' : 'none',
'padding' : '4px',
'opacity' : '.7',
'background' : '#ffffff',
'border' : '1px solid #525252',
'font-size' : '11px'
}
}).injectInside(crop4.wrapper);

// when dragging/resizing begins show indicator
crop4.addEvent( 'onBegin' ,
function(imgsrc,crop,bound,handle){
indicator.setStyle('display' , 'block');
});

// during the event update label
crop4.addEvent('onCrop' ,
function(imgsrc,crop,bound,handle){
indicator.setStyles({
'top' : crop.bottom + 10,
'left' : crop.left
}).setText("w: "+crop.width+
" h: "+crop.height);
});

// once event is done hide label
crop4.addEvent('onComplete' , function(){
indicator.setStyle('display','none');
});
Server handling example (double click on crop area) var crop5 = new MooCrop('crop_example5');

crop5.addEvent('onDblClk', function(img,crop,bound){
$('cropped').src = "crop.php?w="+crop.width+"&h="+crop.height+
"&x="+crop.left+"&y="+crop.top;
});

Upcoming Features

This is still very much a work in progress, I have additional features I am planning on adding in the near future. If there is anything you would like to see added please contact me.
  • Max size constraints
  • Ratio constraints
  • Keyboard events (arrow keys) move crop area 1px shift+arrow moves 10px
  • Crop area initialization can be set or drawn
  • Ability to draw new crop area outside existing area (functioning very much like photoshop)
  • Realtime crop preview
  • Subclassing to allow cropping any element for the use with the css property clip.
Other implementations on the internet use a moving marquee. While it has a nice visual effect I have been hesitant to go this route. It adds 4 more elements that need to be resized or moved. It requires images. I wanted customization with as little hassle as possiblee. Drop the script in and go. If enough people think this is a worth while feature I will look into including it as an option.

Contact

Nathan White: < nw at nwhite.net >









http://72.14.235.104/search?q=cache:YgFXrltT-v0J:www.darkwood.demon.co.uk/PC/crop.htm+crop+border&hl=zh-TW&ct=clnk&cd=99&gl=tw&client=firefox-a
Image Cropper
by Paul Marshall

Overview

Use Image Cropper to -
  • Easily maintain a specific aspect ratio
  • Create anamorphic images for widescreen TV
  • Resize if necessary with high quality
  • Crop for printing in landscape or portrait
  • Batch process with you choosing where to crop
  • Batch process automatically taking best fit to width or height
  • Reduce the size and resolution for Digital Photo Frames
The purpose of this program is to make it easy to crop a batch of images to a specific aspect ratio. The black border area may be included if necessary, and the colour of the border changed. The Safe Area can be shown so you can make sure none of your image will be lost off the edge of a normal TV screen. There's a batch mode with each picture presented to you in turn. All you have to do is decide where to crop and hit 'Save'.

Stills for Video

Primarily designed to crop images for inclusion a in video production where they have to fit a standard 4:3 aspect ratio, or a widescreen 16:9 ratio. If necessary, the image can then be saved in 720 x 576 pixels (for PAL, or 720 x 480 for NTSC) so that it matches standard video. If the crop is 16:9 this will result in an anamorphic image which will be stretched by the TV set so that it looks correctly proportioned. Presets for several standard TV output sizes are included for resizing if necessary. It can be useful to reduce the resolution especially when working with big mega pixel images. Note: if your video editing program can work in 16:9 then don't save as an anamorphic. Normally there is no need to worry about the actual pixel size. Original 4x3 image Cropped to 16:9 widescreen Anamorphic 4x3 output Fit to the safe area and include a black or coloured border

Photo Printing

This program is also useful in preparing photos for printing. For instance, the common print size of 7"x5" doesn't fit the common 4:3 aspect ratio of many digital cameras. Instead of leaving it to the photo printer to crop out the central area you can choose which area to print, and maybe also zoom in a bit. A selection of common sizes is included or custom sizes can be entered. No scaling need be done and there's no need to get involved in dots per inch, just get the height and width in the right proportion and leave the rest to the printers. Re-sizing is not really relevant here, its just the aspect ratio that matters. However if you do you wish to change the size, either larger or smaller, Image Cropper can do so with very good quality. Crop photos for printing.
Two ways to use a portrait photo in a video - crop to the width or include the full height with a border
Automatically add a text label

Batch Processing

A batch facility is included so that a large number of images can be processed quite quickly. This works by allowing multiple files to be selected which are then presented to you one by one so that all you have to do is select the area you want and click Save.
Alternatively, if you just want to crop to the best fit, width or height, then the whole batch can be processed automatically. Optionally, for landscapes the selection fits the width while for portraits a black border is included each side.
View the Image Cropper Help file included with the application for more information.
Electronic photo frames These usually have fairly low resolution so apart from cropping the aspect ratio, by resizing to fit the frame you can pack a lot of photos on to a small memory card. Use up those little ones that come with cameras!
Using some of these frames can be confusing. Some of the pixel ratios can be odd. Image Cropper will help you get the sizes right.
For instance, this one (from Argos) claims "Screen resolution 1440 x 234 pixels (480 RGB x 234)". Although the frame is physically 16x9 the image files need to be 4x3. ( Anamorphic, like widescreen TV). An image saved at 480x234 gives a small squashed picture. For this frame an image has to be saved at 1440x1080 to make it fill the frame properly. Unfortunately the resolution is not really this high!

Levels Adjustment

With Image Cropper you can also adjust the brightness, contrast and colour saturation. There is a histogram display and a reading of RGB value at the mouse pointer. See the Image Cropper Help for more information

Free Download

Feel free to download and use this program, however if you find it useful you could consider making a small donation through If you have any comments, bug reports, feature requests or just to say hello - send me an E-mail. Then if I make any changes I can let you know. Requirements: I developed this under Windows XP. Some users have reported problems when using Windows 98 but regrettably I can't.investigate. Disclaimer: This software is provided 'as is' with no guarantees of any kind. No responsibility can be accepted for problems arising from it's use.

Download Image Cropper Version 1.7.0
  • New 12th June 2008.
  • Can add a Frame to the outside of the image.
  • Settings can be saved and loaded to/from a named file.
  • Change to resizing by dragging corners - opposite corner stays fixed
  • Fixed bug in filename when no extension given.
Screenshot: V.1.5.0 Older versions Download Image Cropper Version 1.6.0 Download Image Cropper Version 1.5.0 Download Image Cropper Version 1.4.7 .Note: This version is designed for a 1280x1024 or larger screen. Download Image Cropper Version 0.93.1 For users with a lower resolution screen. Designed for 1024 x 768 screen. If you have any problems or suggestions for improvements send me an E-mail. Use of this program is free and unrestricted. However, if you find my program useful please consider making a small contribution via PayPal.

Installation

Extract the program file cropper.exe and the help file folder Image Cropper Help into a new folder. Make a short-cut to cropper.exe. An .ini file will be created in the same folder. No registry entries are created. To uninstall simply delete the folder!
A word about Embedded thumbnails and EXIF informationMost digital cameras include a thumbnail image and information about the image, called 'exif', in the jpeg files they create. Jpegs saved by Image Cropper do not include this extra data and normally this is not a problem. However, some TV sets include a memory card reader for directly displaying camera images and these sets use the embedded thumbnail to provide their catalogue. They can take a long time to generate thumbnails from other jpegs such as Image Cropper files. One way around this is to use Image Cropper to resize to 1024 x 576 with a jpeg quality of 80. This will make smaller files while the quality will still be good.
Version History version (0.3) includes output resizing. (A bit slower than some programs maybe, but the quality is very good.) version (0.3b) Same as 0.3 but compiled with different compiler due to jpeg module bug. version (0.4b) includes border colour selection and safe area guide. Help reinstated. version (0.5b) added: exit Preview mode with any key, enter custom resize version (0.7b) added: Options to fit selected area to Safe Area. Safe Area can be varied. Preset resize options. Fully auto batch mode. version (0.8b) added: Rotate image by 90° or 180°. Enlarge border area. Toolbar buttons to access features. 'Save' doesn't show save dialogue - but 'Save As...' does. More preset resolutions. Improved help in html format. More status-bar information version (0.91b) Settings are saved on exit. Selection bounding box is restrained to useable area. Image list can be hidden / shown. Aspect Ratio can be unlocked. version (0.95b)Functionally the same as 0.91b but rearranged screen layout to suit 1280x1024 screen or larger only. version (0.92b) Custom size width and height swaps with Landscape / portrait change. For the 1152 x 864 screen. Likely to be the last in this screen size. version (0.93.1) Re-designed for 1024x768 screen size. Control of selection box improved. Style of box can be changed to improve visibility. version (1.10): Decided to take it out of beta test! Versions before 1.0 will be 1024x768; after 1280x1024 from now on. version (1.20): Control of selection box improved. Style of box can be changed to improve visibility.
Handling of square pictures improved and Square added to aspect list.
Custom resize values can be set to current aspect if required.
1.2.2 Annoying warning message about resizing removed. 1.2.3 Custom Aspect Bug fix
version (1.30): Levels adjustment function added.
1.41 Toolbar button 1.42 Option to save settings between visits
1.44 Additions to presets lists such as A4 aspect ratio
1.46 Show Clipping added to Levels. Memory leak in batch mode fixed.
1.47 Autofit to Width / Height option added
version (1.50):28/12/07 Screen layout redesigned again, now adjusts to different screen resolutions. File list dropped.. version (1.60) 6/2/08. Text overlay function such as to add a copyright message or filename. Basic print function added. Rotate by any angle added. Invert speeded up. Other angles still a bit slow I'm afraid! Aspect Ratio list revised, 'As Image' added. Help V1.5. version (1.70) 12/5/08. Can add a Frame to the outside of the image. Settings can be saved and loaded to/from a named file. Fixed bug in filename when no extension given. Change to way resizing by corners works. Help V 1.7
Use of this program is free and unrestricted. However, if you find my program useful please consider making a small contribution via PayPal.





guide to buying prints
1. Click on your event name. The gallery will open in a new window or tab.
  • If you don't see your event listed, you can do a search. (Please allow two to three days after the event for images to be uploaded).
  • If there are multiple galleries, a list will load. Click on the gallery you want to browse.
2. Browse thumbnails to find your friends and family. Click on a thumbnail to see the photo larger.


3. There are two ways to put photos in your shopping cart
  1. Click on a thumbnail...
    · Choose the print size and quantity.
    · Choose a crop option


    SUGGESTION: Use option 2 or 4 (as labled in the diagram. It will not be labled on the order page).
    · Option 2 prints the photo to the edge of the paper. If the size you choose is not the same shape as the photo you selected, a part of the photo may be cut off.
    · Option 4 will make sure the whole image as selected, fits on the paper size selected.This may leave a white border around your images.


    · Choose a border option: no border, white, black, black on white, white on black




    · Choose a color option




    · Once satisfied with your selections,
    click "ADD TO CART"
    · You can change your crop, border and color selections at this point to add another version of the same image to your cart. Be sure to click
    "ADD TO CART" after you've finished customizing each version of the image.
    · Click "CHECK OUT" to pay or
    "TO GALLERY" (upper left) to select more images

  2. Select multiple images
    · Check the "SELECT" box next to the desired photos. You can select photos on one page and go to the next page to select more. Your selections will be saved even when you change pages.
    If there's a shopping-cart icon where the select box should be, that image is all ready in your cart. You can select print sizes and quantities later.
    · Once you're done selecting, click "ADD TO CART".
    · In the cart, you will choose print size and quantities.
    · Click "CHECK OUT" when done to save your selections.
    · If you want to add print sizes or return
    to the gallery, click "MORE OPTIONS"
    · Modify your print sizes and quantities or
    click "BACK TO GALLERY" (upper left)
    to add more images.
    · Scroll through to check the thumbnails for bad crops (heads cut off, etc.)
    If you find a problem, click "CROP & BORDER" to adjust. Then click "SUBMIT"

  3. Ready for final check out. Once you have sorted through the cart, click "CHECK OUT".
  4. Fill in your shipping information.
  5. Final Purchase Approval page, enter your payment information. If you have a PhotoPass or gift certificate, enter you code on this page.

^
2

^
4

Copyright 2006 Cariño Casas. All Rights Reserved.
Includes Website and images displayed on it, except where noted.
geovisit();
UvumiTools Crop
cropping test
Create Show/Hide Destroy
cropping testcropping test

Description

In today's web2.0 era, more and more websites are user generated and boast dynamic content. Users sumbit text, images, videos, providing content for entire web sites. Most of the time, people submit photos straight from their camera because they don't have photo editing programs or they don't know how to use them. This simplified tool gives your users the ability to create a selection area that can be used to crop an image, live on your web site.

Features

  • Simple: There are some other Javascript image cropping tools out there already. We don't necessarily think they are bad--most of them accomplish the same task, some do it better, but they are frequently too complex for our tastes. With UvumiTools Crop, you don't have a dozen handles and double-click features. Drag from the middle to move, tug on the lower-right corner to resize, and that's it. Simple.
  • Set minimum sizes: If you know the thumbnails on your website will be 120*90 pixels, just set those values as minimums, and your users won't be able to select any smaller area than this. Why? Because if a smaller area is submitted, you have three possibilities:
    • The user will end up with a smaller picture, not filling containers designed for a specific size.
    • The server script will automatically expend the area before cropping to match the minimum size, surprising the user with a thumbnail not matching what was actually selected.
    • The server script will crop the image to this smaller size first, then resize the thumb by expending it to the minimum size, resulting in picture quality loss, especially if the user selected a very small area (like a 30px area for a 120px thumbnail).
    By defining a minimum size, you can avoid these problems.
  • Keep aspect ratio (or not): If you want all the thumbnails on your website to be squared or 4/3 and nothing else, you can lock the aspect ratio to the dimensions you specified as minimums (see above). Selection's height and width will grow and shrink together, maintaining proportions.
  • Real time preview: You can set an element of your document to render a preview of the thumbnail. It might not look as good as an actual resampled image, but it definitely gives your users a good idea of what the resulting image will look like.
  • Support HTML resizing: If the image has been resized to fit in the document, with <img> WIDTH and HEIGHT attributes or with CSS, the script will detect it and still return correct coordinates.
  • Callback function: This feature is very important, because without it this tool would be useless. Making selections on top of a picture is fun, but if you can't do anything with it, what's the point? Once you've created a selection, you must communicate the coordinates to your server-side script so it can perform the actual crop. It will need need two pieces of data: position and dimensions. That's why the cropper has a callback function, fired after every drag on the selection. By default, this function does absolutly nothing, but you can set it do anything when you initialize the script. The callback function recieves four arguments: top, left, width, height. It's up to you to grab those values, and put them in a form to submit to the server-side script. The demo shows how to do that. Ideally you would put them into hidden inputs, with another one referencing the image file to be cropped.
  • Can be toggled on and off: UvumiTools Crop offers tools to completly remove itself from the document (ideal once the the coordinates have been submited to the server) or to hide it so you can show it again later, without completely regenerating a new one. Good for memory management.
  • Modify style with CSS: Style is not hard-coded, you can modify the mask's color, the selection's border color, its thickness and style, with basic CSS. Use the downloadable sample to get started. Some important properties are overwritten by javscript to ensure the script will work, but they don't affect the way it looks. There isn't much you want to modifiy beside the mask and the border colors anyway.
  • Fast, even on slow computers: This one is for advanced CSS users: the other cropping scripts I've seen use a four-DIVs trick to display a mask around the selection. And that's how we initially coded ours--Everytime the selection is moved or resized we had to recalculate the positions and dimentions of the four Div elements. That meant 4 css properties for each div, except the first one which always stayed in the top left corner. But that's still 14 properties to calculate and update on every mouse move. If you add the preview at the same time, it can slow things down a bit.

    Then we found a blog article about the little-known CSS cliping property. It almost does what this mask does: you specify four coordinates within an element (top, right, bottom, left) and it only renders this area, everything else is masked out. It took usa while to figure how to use it in the cropper context, because at first it was doing the opposite of what I wanted: it was rendering the mask only inside the selection, not outside. So in the end we duplicated the picture, and superimposed everything in four layers from bottom to top: original picture, mask, picture clone, selection. Then we applied the clipping property on the image clone, while keeping the mask as a single div covering the original. And that's it. Now when modifiying the selection, all I have to do is update the clip property on the image clone. That's one CSS property to update instead of 14.

Requirements

What you'll need:
  • A server-side script: Unlike other UvumiTools scripts which are mostly client-side only tools, UvumiTools Crop must be paired with a server-side script that will actually be able to so something with the coordinates. We are now providing a sample PHP script to crop images on the server side. It is available in the downloads section below.
  • Mootools 1.2: To use this plugin you'll need Mootools 1.2, but if you are already using another javascript framework like Prototype or JQuery, you may have to decide which one you want to keep because those frameworks were not designed to work together, and they ofen conflict with each other.
    And yes, you actually do need version 1.2 of Mootools. If you are already using a previous version of Mootools then the Crop will not work unless you upgrade. Sure, upgrading is a slight hassle, but trust us, it's worth it in the long run.
  • Mootools Dependencies: If your website already contains some Mootools 1.2 stuff (from this wesite or elsewhere), then you're stoked because you can use a single Mootools library for everything. All you'll need is the UvumiTools Crop script, and to make sure your library contains the following classes:
    • Core
      • Core
      • Browser
    • Native
      • Array
      • Function
      • Number
      • String
      • Hash
      • Event
    • Class
      • Class
      • Class.Extra
    • Element
      • Element
      • Element.Event
      • Element.Style
      • Element.Dimensions
    • Utilities
      • DomReady
    • Fx
      • Fx
      • FX.CSS
      • FX.Tween
    • Plugins
      • Fx.Elements
      • Drag
      • Drag.Move
      • Assets

How To

Initialization

new uvumiCropper(image,options);

Arguments

  • Image: Can be the ID of an image HTML element, or the element it-self, if grabbed the mootools way with the $() function. If you don't understand what it means, just pass the image ID.
  • Options: an object that will allow you to modify some properties of the script. Options are optional (of course). If you just want to keep default value, you don't need this second parameter.

Options

  • maskOpacity: Number between 0 and 1, defining the opacity of the masked overlayed on top of the image. Default is 0.5. To change its color, use the attached CSS file.
  • maskClassName: The css class you want to be applied to the mask, to modify its style with css. Default is cropperMask which corresponds to the name used in the sample CSS file that comes with this plugin.
  • moverClassName: The css class you want to be applied to the middle area that lets you drag the cropping region. You shouldn't have to modify this style. Default is cropperMove which corresponds to the name used in the sample CSS file that comes with this plugin.
  • resizerClassName: The css class you want to be applied to the outter area of cropping region. If you want to overrride the default red dashed border, this is the class you will alter. Default is cropperResize which corresponds to the name used in the sample CSS file that comes with this plugin.
  • wrapperClassName: The css class you want to be applied to the image wrapper. You shouldn't have to modify this style. Default is cropperWrapper which corresponds to the name used in the sample CSS file that comes with this plugin.
  • mini: An object with two values, x and y, defining the size of the thumbnail. These coordinates are used to generate the preview and as minimum size for the cropping region. Default is {x:80,y:80}.
  • onComplete: Event function fired when when you stop dragging/resizing. recieves four parameters: top, left, width, height (of the selection). By default, it's empty, but you can write a function to update a form that contains one hidden input for each coordinate (or one input with a json string, it's up to you). Then by submitting this form to a server script, you should be able to crop your image on the back-end (eg with GD library in PHP, just as we do in the sample script you can download below).
  • resizerWidth: Width of the resizing area (left and bottom margin of the cropping region). Default is 8px wide.
  • resizable: Boolean value, if the selection can be resized or not. Default is true
  • keepRatio: Boolean value, if the width/height ratio of the selection should be maintained or not. Default is true
  • preview: if you want to display a preview of the cropped image, you must specify a target container by its ID. Default is false, which means no preview will be generated. If any string is passed, the script will try to select the element with the corresponding ID.

Implementation

First, you simply import the files provided in the zip archive into your document. While you can insert <script> tags anywhere, we recommend you put them inside the <head> tag:
<head>
<!-- Insert these lines in your document's head -->
<link rel="stylesheet" type="text/css" media="screen" href="css/uvumi-crop.css"/>
<script type="text/javascript" src="js/mootools-for-crop.js"> </script>
<script type="text/javascript" src="js/UvumiCrop.js"> </script>
</head>
Then you must prepare the HTML code. You need one image. Let's just give it the id "myImage".
<div>
<img id="myImage" src="my_image.jpg" alt="My image" />
</div>
"my_image.jpg" is just a random image file name, we just assume it exists. Then we initialize the cropper object with this image's ID. Don't forget to wrap the ID with quotes when passing it to the object (double or single, doesn't matter);
<script type="text/javascript" >
new UvumiCropper('myImage');
</script>
In the end, if we put everything together. Mootools requires a strict Doctype to work properly. Use something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="css/uvumi-crop.css"/>
<script type="text/javascript" src="js/mootools-for-crop.js"> </script>
<script type="text/javascript" src="js/UvumiCrop.js"> </script> <script type="text/javascript" >
new UvumiCropper('myImage');
</script>
</head>
<body>
<div>
<img id="myImage" src="my_image.jpg" alt="My image" />
</div>
</body>
</html>
You should get something like this. A cropper with default options: 80*80 pixels, resizable, keeps aspect ratio, no preview, 50% opacity mask
example 1example 1
Let's try a step above. This time, we'll set no fixed ratio, with a preview. First part where you include the required script is the same. But you'll need an existing container for preview (because the script is not supposed to guess where to display it). Where just going to create an empty div, with id "myPreview".
<div>
<div id="myPreview" </div> <img id="myImage" src="my_image.jpg" alt="My image" />
</div>
Then we must tell the script to use this div as a preview container when we initialize the object, with the preview option. We also said we didn't want to keep the selection's aspect ratio, so we're going to set keepRatio to false
<script type="text/javascript" >
new UvumiCropper('myImage',{
keepRatio:false,
preview:'myPreview'
});
</script>
Put it together:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="css/uvumi-crop.css"/>
<script type="text/javascript" src="js/mootools-for-crop.js"> </script>
<script type="text/javascript" src="js/UvumiCrop.js"> </script> <script type="text/javascript" >
new UvumiCropper('myImage',{
keepRatio:false,
preview:'myPreview'
});
</script>
</head>
<body>
<div>
<div id="myPreview" </div> <img id="myImage" src="my_image.jpg" alt="My image" />
</div>
</body>
</html>
And you should get something like this. Try to resize the selection and check out how the preview reacts.
example 2
example 2example 2
One more example: we're going to modify the genearal look of the cropper by assigning alternate CSS classes. We are also going to change the default minimum width and height, and, just to show that it's possible, disable resizing.
<script type="text/javascript" >
new UvumiCropper('myImage',{
maskOpicity:0.3,
maskClassName:'blueMask',
resizerClassName:'yellowSelection',
mini:{
x:120,
y:90
},
resizable:false
});
</script>
HTML will be the same as the first exemple, but we are going to create new CSS classes, corresponding the those we set in the cropper's options
<style type="text/css" >
.yellowSelection{
border: 2px dotted #FFB82F;
}

.blueMask{
background-color:#00f;
cursor:pointer;
}
</style>
Resulting code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="css/uvumi-crop.css"/>
<style type="text/css" >
.yellowSelection{
border: 2px dotted #FFB82F;
}

.blueMask{
background-color:#00f;
cursor:pointer;
}
</style>
<script type="text/javascript" src="js/mootools-for-crop.js"> </script>
<script type="text/javascript" src="js/UvumiCrop.js"> </script> <script type="text/javascript" >
new UvumiCropper('myImage',{
maskOpacity:0.3,
maskClassName:'blueMask',
resizerClassName:'yellowSelection',
mini:{
x:120,
y:90
},
resizable:false
});
</script>
</head>
<body>
<div>
<img id="myImage" src="my_image.jpg" alt="My image" />
</div>
</body>
</html>
Should produce this, if not, go back and check for typos or mistakes:
example 3example 3
Ok, last but not least, we'll look at how the callback function works. At the same time, we are going to demontrate the HTML resizing feature: We are going to pick an 800px wide image, but we are going to scale it down to 400px match with the other. So techincally, when we draw a 100px*100px selection on this scaled down image, it virtually represents 200*200px on the full size image, the one the server will use. Same goes with top and height, and preview too, everything has to match this X2 factor. The script handles it and does all the conversion for you, if the image has been scaled up or down. We prepare the HTML first. We are going to create a form with four inputs. For the image, we are going to set the WIDTH attribute (we can either set here or with CSS, works with height too):
<div>
<img id="myImage" width="400" src="my_image.jpg" alt="My image" />
</div>
<form action="crop-image.php" method="post" >
<p>
<input id="input-top" name="top" type="text" readonly="readonly" />
<input id="input-left" name="left" type="text" readonly="readonly" />
<input id="input-width" name="width" type="text" readonly="readonly" />
<input id="input-height" name="height" type="text" readonly="readonly" />
<input name="image" value="my_image.jpg" type="hidden" />
</p>
<p>
<button type="submit" > Send </button>
</p>
</form>
Note that we create four read-only text inputs for this example, but in a real production environment, we'd probably set them as hidden, just like the one containing the image name (or any other kind of unique identifier). Now we want to synchronize those inputs with our cropper:
<script type="text/javascript" >
new UvumiCropper('myImage',{
onComplete:function(top,left,width,height){
$('input-top').set('value', top);
$('input-left').set('value', left);
$('input-width').set('value', width);
$('input-height').set('value', height);
}
});
</script>
It's that simple!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="css/uvumi-crop.css"/>
<script type="text/javascript" src="js/mootools-for-crop.js"> </script>
<script type="text/javascript" src="js/UvumiCrop.js"> </script> <script type="text/javascript" >
new UvumiCropper('myImage',{
onComplete:function(top,left,width,height){
$('input-top').set('value', top);
$('input-left').set('value', left);
$('input-width').set('value', width);
$('input-height').set('value', height);
}
});
</script>
</head>
<body>
<div>
<img id="myImage" width="400" src="my_image.jpg" alt="My image" />
</div>
<form action="crop-image.php" method="post" >
<p>
<label for="input-top" >Top: </label> <input id="input-top" name="top" type="text" readonly="readonly" />
<label for="input-left" >Left: </label> <input id="input-left" name="left" type="text" readonly="readonly" />
<label for="input-width" >Width: </label> <input id="input-width" name="width" type="text" readonly="readonly" />
<label for="input-height" >Height: </label> <input id="input-height" name="height" type="text" readonly="readonly" />
<input name="image" value="my_image.jpg" type="hidden" />
</p>
<p>
<button type="submit" > Send </button>
</p>
</form>
</body>
</html>
You can see the form's inputs being updated whenever you release the selection. Note how the values are twice as large as the actual selection because the picture is scalled down by 50%:
example 4example 4
Actual picture size : 800*698 pixels
Displayed size : 400*349 pixels
Coordinates generated match the picture's real size.
Top: Left: Width: Height: Send

Known Issues

  • Rounding problems: This only happens when dealing with images directly resized on the client side, especially with images scaled down. Coordinates need to be multiplied by a ratio to get the actual size. The result must be rounded to get a pixel value, and sometimes it's rounded to the upper value when that's not desirable. What happens? In the worst case scenario, you may end up with a selection area popping one pixel out of the picture. We'll try to fix this in the future.

Download

Mootools Library for UvumiTools Crop. Limited MooTools version custom-built for optimal UvumiTools Dock performance. This version of the MooTools library only contains the classes necessary for the Dock Menu plugin, so if you want to use this plugin with other Mootools plugins (including other UvumiTools Plugins), we recommend you build your own library from scratch on the Mootools website, or just download and use the whole Mootools script. Make sure you use version 1.2 and that you include all the classes described in the Requirements section above. Compressed script. If you are not a javscript geek and don't want to mess with the code, check this. Uncompressed and Commented script, if you are familliar with Mootools framework and think you can improve it, help yourself. CSS files. This includes the style sheet and images needed to get the result visible above. Demo. Contains the HTML code to generate the same example as above. PHP cropping sample to actually crop an image for real on a server, when you submit the coordinates generated with this plugin Download

Change Log

  • 20080910 - Version 1.0.1: Added a PHP sample cropping script to the download package
  • 20080902 - Version 1.0.0: Initial release. Stable with Mootools 1.2
window.google_render_ad();


rockyen
rockyen
Latest page update: made by rockyen , Sep 20 2008, 5:03 AM EDT (about this update About This Update rockyen Edited by rockyen

5408 words added
28 images added

view changes

- complete history)
Keyword tags: None
More Info: links to this page
There are no threads for this page.  Be the first to start a new thread.