Scripting and Crop and Straighten photos

photoshop CS3 has this neat feature "Crop and Straighten photos" which is very helpful in cleaning up scanned images (remove the black border) but is there a way to turn it into an action ?
i would like to apply this against many images (lots of files) in an automated way but being new to scripts/actions, I haven't had much success since this command creates a copy of the original.
is there an action that will help me batch remove the black border from all my images either using this CS3 command or another. thanks

OK, I'm giving back: here's an adaptation of Paul's script that uses recursion to iterate through all subdirectories. (Note that I also changed the file name suffix to a "static" (non-sequenced) value, as well as the name of the output folder, since I am using this to process single-photo image files. The original lines are commented out.) To implement the recursion, I defined the "main" functionality in a function ("ProcessFiles") that calls itself when encountering a subfolder.
Here's the full script. Hope this helps someone!
===========================
// Prompts the user for a directory, and then recursively processes each image
// in that directory and all subdirectories by executing the "Crop and
// Straighten" command. Images are saved with a specified suffix in a
// designated subfolder.
// Adapted from a script provided by "Paul R." in the "Photoshop Scripting" forum
// http://www.adobeforums.com/webx?7@@.59b54905/2
// TIP: Hold down the "Alt" key while running this script to instruct Photoshop
// to treat the image as a single photo. (For more information, see:
// http://livedocs.adobe.com/en_US/Photoshop/10.0/help.html?content=WSfd1234e1c4b69f30ea53e4 1001031ab64-762e.html)
#target Photoshop
app.bringToFront;
var inputFolder = Folder.selectDialog("Please select folder to process");
if(inputFolder != null){
ProcessFiles(inputFolder);
function ProcessFiles(inFolder) {
// var fileList = inFolder.getFiles(/\.(jpg|tif||psd|)$/i);
var fileList = inFolder.getFiles();
var outfolder = new Folder(decodeURI(inFolder) + "/Cropped");
if (outfolder.exists == false) outfolder.create();
for(var a = 0 ;a < fileList.length; a++){
if(fileList[a] instanceof File && fileList[a].name.match(/\.(jpg|tif||psd|)$/i)){
var doc= open(fileList[a]);
doc.flatten();
var docname = fileList[a].name.slice(0,-4);
CropStraighten();
doc.close(SaveOptions.DONOTSAVECHANGES);
var count = 1;
while(app.documents.length){
// var saveFile = new File(decodeURI(outfolder) + "/" + docname +"#"+ zeroPad(count,3) + ".tif");
var saveFile = new File(decodeURI(outfolder) + "/" + docname + "-CR"+ ".tif");
SaveTIFF(saveFile);
activeDocument.close(SaveOptions.DONOTSAVECHANGES) ;
count++;
else if (fileList[a] instanceof Folder) {
// alert("Folder: " + fileList[a]);
ProcessFiles(fileList[a])
else {
// inappropriate file type, or null
function CropStraighten() {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
executeAction( sTID('CropPhotosAuto0001'), undefined, DialogModes.NO );
function SaveTIFF(saveFile){
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
activeDocument.saveAs(saveFile, tiffSaveOptions, false, Extension.LOWERCASE);
function zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;

Similar Messages

  • I am scanning black/white photos and making a few adjustments - retouching and cropping.  The photos then turn red.  Why?

    I am scanning black/white photos and making a few adjustments - retouching and cropping.  Some (only some) of the photos turn red. Why and what do I do to correct this problem?

    This is because we've scanned the photo's using grey scale. 
    Through further searching I found a solution thanks to Terence.  You can convert your already scanned photos to the required sRGB format by doing the following:
    Open Automator.  Select your photo's that need converting from the file and drop into Automator.
    You can create an Automtor workflow to assign an sRGB profile to images.
    The variable you want is 'Apply ColorSync Profile' to images and then select sRGB from the drop down.
    Hope this helps! 

  • Crop and Straighten Images Settings

    I'm trying to use Photoshop  CS5 to crop and straighten images of postage stamps.  E.g., place a  bunch of stamps on the scanner bed and scan them as one image.  Then use  Automate/Crop and Straighten Photos to create separate workspaces each  with a single stamp image, cropped and rotated appropriately.  This  almost works; the problem is it often crops the stamps too closely,  cutting off the perforations.
    Here are a few once cropped.
    So is there a way to set the border?  Thanks in advance.

    Using  paths and the stroke paths function, like in this video, should get you
    decent results with the crop and straighten function.
    Look down the page under CS2 and Crop and Straighten updated:
    http://www.russellbrown.com/tips_tech.html
    This:
    To this:
    MTSTUNER

  • Crop and resize images on iPhone - app recommendations?

    Does anyone know of a photo-editing app for iPhone that lets you crop an image and also resize to a preferred pixel ratio?
    On my Mac at home I use Photoshop for this (setting the crop-to width at 500 px and then simply cropping the part of the image I want to use), but it would be super-handy if I could load the high-res images onto my iPhone and do it on the move.
    I tried the Photoshop app, but although it lets you crop, there doesn't seem to be a resize function.
    Any ideas?

    Hi Jennifer, I guess It's not possible do what I want directly from iPhone.
    My problem is pinch to small size and keep it then and send to Instagram. When I double tap the image enlarge, so I double tap again and the image go back to normal size. When I pinch to small size that I want and leave my fingers the image goes back to regular size.
    I'm reading others foruns and I guess I have to use some app to post 3:4 photo, like Squaready. I'm trying and seems It work. It need to resize and crop and make all adjustments.
    Thanks for help.

  • Cropping and Combining Images

    Is there a way to take multiple images (i.e. congruent squares of a map) and crop and combine them to form one image of a given size?
    For example, if the user asks for a map of a certain area with a bounding box of 40 to 57 (x) and 33 to 50 (y), I want to return an image made up of individual smaller squares from the map database cropped to cover only those coordinates. Unforturnately the map in our database is a series of squares each 10 by 10 (i.e. (0-10, 0-10), (10-20, 0-10), and so on). So I need some way to take the (40-50, 30-40), (50-60,30-40),(40-50, 40-50), and (50-60,40-50) images and combine and crop them to make an image that covers only (40-57,33-50).
    Is there a class somewhere that allows for such an operation, or if not, does anyone know an easy way to do this?

    I'll assume you are looking to create an arbitrary rectangular image from a domain of rectangular images that collectively form a contiguous grid. Right?
    This is a fairly simple problem to solve...
    1. Create a BufferedImage with bounds equal to your bounding box. Then create a Graphics2D from the BufferedImage via BufferedImage.createGraphics().
    2. Determine the images in the database that intersect your bounding box.
    3. For each intersecting image determine the portion of the image that is contained in the bounding box. Then translate each image portion's coordinates to your bounding rectangle's coordinates.
    4. Using the graphics from step 1 call Graphics.drawImage() to render each image portion to the BufferedImage using the translated coordinates.
    5. The BufferedImage is now an in memory representation of your bounding box selection.

  • Crop And Straighten Photos - Changing parameters / Editing Script

    Hi. I am currently using the Crop and Straighten Photos automation to crop scans of 10 to 12 maps that are scanned on a large flat bed scanner.
    A lot of the plans have rough edges and aren't always completely square. Is it possible to allow a tolerance (eg. 5mm, or 20pixels etc) before cropping each image? I've tried editing a .jsx script that was submitted on this forum (the script was designed to crop more border from the image, as opposed to leaving more image) but this simply added a black border around my image as it enlarged the canvas side once the image had already been cropped.
    Instead, I need the selection area to be increased prior to cropping.
    Does anyone have an idea on whether I can get a script to do what I am looking for?
    Furthermore, if two or more of the maps are joined at all by a hair or a frayed string of canvas from the map's backing then the Crop and Straighten Photos automation considers it to be one map and crops it as only one image. Is there a way of increasing this tolerance to make the cropping process more brutal so to speak?
    Any help would be greatly appreciated.

    Hi Christoph.
    I'd realised that once i made the post, and yes, the duplicate and flatten parts in the process are unnecessary, they have been removed. The action is set up now so that once it crops the individual images, it closes the main image down, and then saves and closes the individual images. It is setup to save and close 12 images (as this is the most there will ever be in my case), and I set the action to post errors to a log rather than halt, so if there are less than 12 files it will continue and just post an error in the file. It works really well now thanks!!
    I then run an action that options each individual file and brings up the "save as" dialog. This is a chance to perform a QA on the image and to save it as the correct name on the plan.
    However, the action is currently setup so that it creates a complete new image each time and closes the original. This is the only way I can make the "Save as" dialog point to the new destination as if I simply open and "save as" the original files, the default folder always resets back to the original folder where the cropped images are. I'll have to investigate other methods of opening and renaming the images to help speed this part of the process up.
    Thanks so much for your effecient responses. They have been a great help!
    Cheers.

  • The trial version of Adobe photoshop 13 does not have the Crop And Straighten Photos option  under file and automate....... all it has is "Fit Image".......   would really like to have that feature.... is it something they eliminated?

    I am scanning in many old photos and there are several photos on one page.... I read about a feature that was suppose to be available under adobe photo shop elements 13 that would allow multiple cropping under the file, automate, Crop And Straighten Photos....... the only thing that displays on the version 13 that I have is "Fit Image"...... which doesn't help me......    have they removed this tool or do you have to crop and save one image at a time?    Thanks for your help?

    You want Image>Divide Scanned Photos

  • Photoshop Help | Crop and straighten photos ❘ CS6

    This question was posted in response to the following article: http://helpx.adobe.com/photoshop/using/crop-straighten-photos.html

    Russell Brown (Senior Creative Director at Adobe) Tips and Techniques:
    http://av.adobe.com/russellbrown/CropAndStraightenSM.mov

  • Crop and Straighten Photos in CS6

    I open a 8"x10" jpeg or any other photo then go over to FILE menu and drop down to AUTOMATE then over to CROP and STRAIGHTEN PHOTO,S
    Now what happens is that three other copies appear copy ,copy  2 copy 3 .
    My original is OK at 8"x10" followed by the copy being 5"X7" then copy2 is about 1/2"x2" and copy 3 is about 3/4"x3/4"
    I think this is being caused by interaction with CS5 as the same happens there.
    CS4 is all OK this not being affected.
    Now in CS4 i can crop and straighten but in CS5 and CS6 nothing can be done.
    Kip

    OK, here's the scoop:  the feature in File>automate>crop and straighten is designed for those who scan in several photos with white space between them. It will make it's best attempt at separating each photograph by looking for the white space around them. It will then crop each photo to the edges it determines and make each straight based on the detected edge.
    It is not designed to straighten the image in a photo.  If you run this on a photograph, it is looking really hard for white space and will make its best attempt to separate what it thinks are independent items or photos and save each to a file.
    If you want to straighten an image, go to the ruler tool and draw a line and choose straighten layer to get a rotation only, or go to the crop tool and select straighten, and draw a line that you wish to be the horizontal. This one will crop also.
    I hope that clears up the issue.
    Pattie

  • Straightening and cropping scanned photos...is there a trick for this?

    Hi,
    I am scanning a bunch of photos of various sizes/shapes.  If I place the photos right up against the edge of the scanner, it crops it.  So what I have been doing is eyeballing it a couple of centimeters away from the edge.  Naturally it is slightly off as far as being aligned straightly.  I have been using transform to adjust the photo so it is straight.  Is there any trick within Photoshop to align it according to the images edges?
    Also, is there any way to use the wand (to basically select all of a photo) and then crop the selected?
    Thanks!
    PS. Since the photos are of various sizes I cannot use a holder.

    If the scanner is cropping the very edge of the glass off, try putting a piece of white tape down on the glass - maybe a 1/2 inch wide strip exactly parallel to the scanner edge. You can then slide your prints up to that and they will be aligned and within the scannable area.
    There are a couple of ways to easily deal with your current crop (pun intended) of scans. The easiest way is to just use the Crop Tool to both crop and rotate at the same time, but make sure that you leave the resolution blank in the crop tool options at the top. The second is to use the Ruler Tool to measure along any of the sides of your scan. That angle will be recorded automatically in the Image>Rotate>Arbitrary dialog, where you can rotate the image back square again. You'll then have to crop it, so you might as well just do it in one fell swoop with the crop tool.

  • Crop and Straighten not separating photos but is producing a single image file.

    I have been trying to use crop and straighten on multiple scanned images and am getting very disappointing results. Instead of separating each of the images with white space around them into individual files, I am getting back a single image of the entire scanned area. Is there a setting I am missing? When I was using CS3 it was no problem, it would have its occasional glitches, but nothing major. CS6 isn't even trying to separate the images.

    Could you please post one of the images (or a lores version of it) that produce unsatisfactory results?

  • Cs3 straighten and crop , is there a way like cs5?

    Hi
    on my laptop i run xp adn photoshop cs3 normal (not extended)
    what i miss is a good straighten and crop like cs5
    in cs3 i use the ruler tool ->rotate canvas -> arbitrary
    and i my photo is straight but with big borders around the photo
    now cs5 does a great job
    but photoshop cs3 no
    there is the scipt straighten and crop photos but in this case doesn't do a great job
    because delete the borders and my photo returns to be awry
    ok i can crop manually , but it's exhausting if i have to work on some photos , one by one
    is there a script/action/tips or plugin  that can do the same great cs5 job?
    thanks
    cheers

    This sets the rulerunits to Pixels then when finished resets them back to what they were....
    // ================================================================================================
    // Script Name: autocrop.js
    // ================================================================================================
    // Version 2.0 9 December 2003
    // Description: crops the active document after image rotation
    // This version is compatible with Photoshop CS and will not run on Photoshop 7
    // This script is product of Paul Jaruszewski and Roger Cavanagh
    // Contact Paul at www.melor.com
    // Contact Roger at www.rogercavanagh.com
    // This script is provided free for personal use.
    // No liability will be accepted for any consequences arising from the use of this script.
    // This script may be copied IN ITS ENTIRETY to others provided and no charge is made other
    // than for media. Credit to Paul and Roger must be made if this script is posted for download
    // or distribution.
    // Installation: copy the file autocrop.js to the ..\Presets\Scripts folder
    // Globals
    var chosenMethod = 0;
    var ui_NoOpenDocuement = "No open document";
    var hlpMsg = new Array();
    var msg = "";
    var hid_BinChop = 1;
    msg = "Binary Search will usually be the fastest method to find edges, but may be slower than the ";
    msg = msg + "Slice method with smaller amounts (1-2 degrees) of rotation. May produce an over";
    msg = msg + "-crop, if the search inadvertently matches the background colour inside the picture.";
    hlpMsg[hid_BinChop] = msg;
    var hid_Slice = 2;
    msg = "Almost as fast as binary search method, but will sometimes produce slight over-crop. This ";
    msg = msg + "can be avoided by ensuring the background colour is different from the edges (10 px) ";
    msg = msg + "colour in the picture";
    hlpMsg[hid_Slice] = msg;
    var hid_UniPixel = 3;
    msg = "This is much the slowest search method, but will only produce an error, ";
    msg = msg + "if edges pixels are the same colour as the background.";
    hlpMsg[hid_UniPixel] = msg;
    var hid_BestResults = 4;
    msg = "For best results, you should make sure the background colour does not occur near the top ";
    msg = msg + "left corner of your picture. If the picture contains predominantly dark colours, ";
    msg = msg + "set a white background before image rotation, and vice versa.";
    hlpMsg[hid_BestResults] = msg;
    // ================================================================================================
    function settingDialog() { // Creates dialog window and gets user input         ===settingDialog===
    // ================================================================================================
    // These are functions in scope for settingDialog ()
    // ------------------------------------------------------------------------------aboutBtnOnClick---
    function aboutBtnOnClick() {
    var msg = "Autocrop V2\n\n\Copyright \u00A9 2003 Paul Jaruszewski and Roger Cavanagh\n";
    msg = msg + "www.melor.com - www.rogercavanagh.com\n";
    msg = msg + "Information: http://www.rogercavanagh.com/actions/15_autocrop.htm";
    dlg.msgPnl.helpMsgSt.text = msg;
    } // end about BtnOnClick
    function cancelBtnOnClick() { // -----------------------------------------------cancelBtnOnClick---
    dlg.close();
    } // end cancelBtnOnClick
    function evalMethod() { //------------------------------------------------------------evalMethod---
    var result = 0;
    if (dlg.methodPnl.binChop.value) { result = 1; };
    if (dlg.methodPnl.slice.value) { result = 2; };
    if (dlg.methodPnl.uniPixel.value) { result = 3; };
    return result;
    } // end function evalMethod
    function runBtnOnClick() { // -----------------------------------------------------runBtnOnClick---
    chosenMethod = evalMethod();
    dlg.close();
    } // end runBtnOnClick
    function displayHelp(hlpMsgId) { // -------------------------------------------------displayHelp---
    dlg.msgPnl.helpMsgSt.text = hlpMsg[hlpMsgId];
    } // end function
    // Standard Values
    var mgn = 10;
    var mgnTop = 20;
    var rowH = 20;
    var rBtnW = 120;
    var btnW = 100;
    // Method Panel Parameters                                           ---Method Panel Parameters---
    var ul_MethodPnlTitle= "Method:";
    var methodPnlRows = 3;
    var methodPnlCols = 1;
    var methodPnlH = methodPnlRows*(mgn + rowH) + mgnTop;
    var methodPnlW = 350; // (methodPnlRows + 1)*mgn + rBtnW; // max number of items
    var methodPnlX = mgn;
    var methodPnlY = mgn;
    // Control Panel Parameters                                          ---Control Panel Parameters---
    var ul_ControlPnlTitle = "Control Panel:";
    var ul_Run = "Run";
    var ul_Cancel = "Cancel";
    var ul_About = "About";
    var controlPnlRows = 3;
    var controlPnlCols = 1;
    var controlPnlH = methodPnlH;
    var controlPnlW = btnW + (controlPnlCols + 1)*mgn
    var controlPnlX = methodPnlX + methodPnlW + mgn;
    var controlPnlY = mgn;
    // Message Panel Parameters                                          ---Message Panel Parameters---
    var ul_MsgPnlTitle = "";
    var msgPnlH = 140;
    var msgPnlW = methodPnlW + controlPnlW + mgn;
    var msgPnlX = mgn;
    var msgPnlY = methodPnlY + methodPnlH + mgn;
    var ul_BinarySearch = "Binary Search";
    var ul_PixelSlice = "Pixel Slice";
    var ul_SinglePixel = "Single Pixel";
    // Dialog Window Parameters                                          ---Dialog Window Parameters---
    var uiTitle = "Autocrop";
    var numPnlsAcross = 2;
    var numPnlsDown = 2;
    var dlgX = 100;
    var dlgY = 100;
    var dlgH = methodPnlH + msgPnlH + (numPnlsDown + 1)*mgn;
    var dlgW = methodPnlW + controlPnlW + (numPnlsAcross + 1)*mgn;
    var bounds = new Array(4);
    var x1 = 0, x2 = 0, y1 = 0;
    // Create window and panels                                          ---Create window and panels---
    bounds = {x:dlgX, y:dlgY, width:dlgW, height:dlgH};
    var dlg = new Window("dialog", uiTitle, bounds);
    bounds = {x:methodPnlX, y:methodPnlY, width:methodPnlW, height:methodPnlH};
    dlg.methodPnl = dlg.add("panel", bounds, ul_MethodPnlTitle);
    bounds = {x:controlPnlX, y:controlPnlY, width:controlPnlW, height:controlPnlH};
    dlg.controlPnl = dlg.add("panel", bounds, "Control Panel:");
    // Method Panel Elements                                                ---Method Panel Elements---
    x1 = mgn;
    y1 = mgnTop;
    bounds = {x:x1, y:y1, width:rBtnW, height:rowH};
    dlg.methodPnl.binChop = dlg.methodPnl.add("radiobutton", bounds, ul_BinarySearch);
    dlg.methodPnl.binChop.value =  true;
    dlg.methodPnl.binChop.onClick = function() { displayHelp(hid_BinChop); };
    y1 = y1 + rowH +mgn;
    bounds = {x:x1, y:y1, width:rBtnW, height:rowH};
    dlg.methodPnl.slice = dlg.methodPnl.add("radiobutton", bounds, ul_PixelSlice);
    dlg.methodPnl.slice.onClick = function() { displayHelp(hid_Slice); };
    y1 = y1 + rowH +mgn;
    bounds = {x:x1, y:y1, width:rBtnW, height:rowH};
    dlg.methodPnl.uniPixel = dlg.methodPnl.add("radiobutton", bounds, ul_SinglePixel);
    dlg.methodPnl.uniPixel.onClick = function() { displayHelp(hid_UniPixel); };
    // Control Panel Elements                                              ---Control Panel Elements---
    x1 = mgn;
    y1 = mgnTop;
    bounds = {x:x1, y:y1, width:btnW, height:rowH};
    dlg.controlPnl.runBtn = dlg.controlPnl.add("button", bounds, ul_Run);
    dlg.controlPnl.runBtn.onClick = function() {runBtnOnClick();};
    y1 = y1 + rowH + mgn;
    bounds = {x:x1, y:y1, width:btnW, height:rowH};
    dlg.controlPnl.cancelBtn = dlg.controlPnl.add("button", bounds, ul_Cancel);
    dlg.controlPnl.cancelBtn.onClick = function() {cancelBtnOnClick();};
    y1 = y1 + rowH + mgn;
    bounds = {x:x1, y:y1, width:btnW, height:rowH};
    dlg.controlPnl.aboutBtn = dlg.controlPnl.add("button", bounds, ul_About);
    dlg.controlPnl.aboutBtn.onClick = function() {aboutBtnOnClick();};
    // Message Panel Elements                                              ---Message Panel Elements---
    bounds = {x:msgPnlX, y:msgPnlY, width:msgPnlW, height:msgPnlH};
    dlg.msgPnl = dlg.add("panel", bounds, "");
    x1 = mgn;
    y1 = mgn;
    bounds = {x:x1, y:y1, width:msgPnlW - 2*mgn, height:msgPnlH - 2*mgn};
    dlg.msgPnl.helpMsgSt = dlg.msgPnl.add("statictext", bounds, "", {multiline: true});
    displayHelp(hid_BestResults);
    return dlg;
    } // end settingDialog ========================================================end settingDialog===
    // ================================================================================================
    function main() { //                                                                     ===main===
    // ================================================================================================
    // These are functions in scope for main()
    function doCropUniPixel() {   // Single Pixel Search Routine ---------------------doCropUniPixel---
    // Declare and Initialise
    var picrgb = new Array(3);
    var backrgb = new Array(3);
    var bounds = new Array(4);
    var j = 0;
    backrgb=eyeDropper(0,0); //Find color of upper left pixel
    var maxi = docRef.width;
    if (maxi > docRef.height) {
        maxi = docRef.height;
    maxi = Math.floor(maxi/2);
    loopOne:
    for (j=1;j < maxi; j++) {
      picrgb=eyeDropper(j,j);
      if (backrgb[0] != picrgb[0] || backrgb[1] != picrgb[1] || backrgb[2] != picrgb[2]) { // edge!
       bounds = new Array(j, j, docRef.width - j, docRef.height - j);
       docRef.crop(bounds);
       bounds = null;
       break;  // Exit for loop
      purge(PurgeTarget.ALLCACHES);
    } // end for
    // prep for looptwo
    var maxi = docRef.width;
    if (maxi > docRef.height) {
        maxi = docRef.height;
    maxi = Math.floor(maxi/2);
    loopTwo:
    for (j=1;j < maxi; j++) {
      picrgb=eyeDropper(docRef.width - j,j);
      if (backrgb[0] != picrgb[0] || backrgb[1] != picrgb[1] || backrgb[2] != picrgb[2]) { // edge
       bounds = new Array(j, j, docRef.width - j, docRef.height - j);
       docRef.crop(bounds);
       bounds = null;
       break;  // Exit for loop
      purge(PurgeTarget.ALLCACHES);
    } // end for
    } // end function doCropUniPixel
    function doCropBinChop() {   // Binary Search Routine -----------------------------doCropBinChop---
    // Declare and Initialise
    var picrgb = new Array(3);
    var backrgb = new Array(3);
    var bounds = new Array(4);
    var j = 0;
    var ub= 0;
    var lb = 0;
    backrgb=eyeDropper(0,0); //Find colour of upper left pixel
    var maxi = docRef.width;
    if (maxi > docRef.height) {
        maxi = docRef.height;
    ub = Math.floor(maxi/2);
    loopOne:
    while (ub - lb > 1) {
      j = Math.floor((ub - lb)/2) + lb;
        picrgb=eyeDropper(j,j);
       if (backrgb[0] != picrgb[0] || backrgb[1] != picrgb[1] || backrgb[2] != picrgb[2]) {
       ub = j;
      } else {
       lb = j;
      } // end if
      purge(PurgeTarget.ALLCACHES);
    } // end while
    bounds = [ub , ub , docRef.width - ub , docRef.height - ub ];
      docRef.crop(bounds);
      bounds = null;
    // prep for looptwo
    maxi = docRef.width;
    if (maxi > docRef.height) {
        maxi = docRef.height;
    lb = 0;
    ub = Math.floor(maxi/2)
    loopTwo:
    while (ub - lb > 1) {
      j = Math.floor((ub - lb)/2) + lb;
        picrgb=eyeDropper(docRef.width - j,j);
       if (backrgb[0] != picrgb[0] || backrgb[1] != picrgb[1] || backrgb[2] != picrgb[2]) {
       ub = j;
      } else {
        lb = j;
      } // end if
    purge(PurgeTarget.ALLCACHES);
    } // end while
    bounds = [ub , ub , docRef.width - ub , docRef.height - ub];
      docRef.crop(bounds);
      bounds = null;
    } // end function doCropBinChop
    function doCropSlice() { // +10 Pixel Routine ---------------------------------------doCropSlice---
    // Declare and Initialise
    var picrgb = new Array(3);
    var backrgb = new Array(3);
    var bounds = new Array(4);
    var j = 0;
    var jInc = 10;
    var maxi = docRef.width;
    if (maxi > docRef.height) {
       maxi = docRef.height;
    backrgb=eyeDropper(0,0); //Find colour of upper left pixel
    j = 1;
    loopOne:
    while (j < maxi) {
        picrgb=eyeDropper(j,j);
       if (backrgb[0] != picrgb[0] || backrgb[1] != picrgb[1] || backrgb[2] != picrgb[2]) {
        if (jInc == 1) {
           bounds = [j, j, docRef.width - j, docRef.height - j];
           docRef.crop(bounds);
           bounds = null;
           break loopOne;
          } else {
           j = j - jInc;
           if (j < 0) {
            j = 0;
           jInc = 1 ;
      purge(PurgeTarget.ALLCACHES);
      j = j + jInc;
    } // end while
    maxi = docRef.width;
    if (maxi > docRef.height) {
       maxi = docRef.height;
    jInc = 5;
    j = 1;
    loopTwo:
    while (j < maxi) {
        picrgb=eyeDropper(docRef.width - j,j);
       if (backrgb[0] != picrgb[0] || backrgb[1] != picrgb[1] || backrgb[2] != picrgb[2]) {
        if (jInc == 1) {
        bounds = [j, j, docRef.width - j, docRef.height - j];
          docRef.crop(bounds);
          bounds = null;
           break loopTwo;
          } else {
           j = j - jInc;
           if (j < 0) {
            j = 0;
           jInc = 1;
      purge(PurgeTarget.ALLCACHES);
      j = j + jInc;
    } // end while
    } // end function doCropSlice
    function eyeDropper(x,y) { // --------------------------------------------------------eyeDropper---
    // This function returns the three values for the RGB colours of any given pixel
    var x2 = x + 1;
    var y2 = y + 1;
    var out = new Array(3);
    docRef.selection.select([[x,y], [x2,y], [x2,y2], [x, y2]], SelectionType.REPLACE, 0, false);
    for(ch in list = ["Red", "Green", "Blue"]) {
    histogram = docRef.channels[list[ch]].histogram;
      for (i = 0; i <= 255; i++) {
       if (histogram[i]) {
        out[ch] = i;
        break;
      } // end for
    } // end for
      return out;
    } // end function eyeDropper
    // Start of main() processing                                      ---Start of main() processing---
    if ( documents.length <= 0 ) {
       alert(ui_NoOpenDocument); // so we crash out
        return;
    try {
      var docRef = activeDocument;
            var startRulerUnits = app.preferences.rulerUnits;
            app.preferences.rulerUnits = Units.PIXELS;
      var settings = settingDialog(chosenMethod);
      settings.show();
      switch(chosenMethod) {
       case 1:
        doCropBinChop();
        break;
       case 2:
        doCropSlice();
        break;
       case 3:
        doCropUniPixel();
        break;
      } // End switch
        app.preferences.rulerUnits = startRulerUnits;
    } catch (e) {
            app.preferences.rulerUnits = startRulerUnits;
       alert("Something's bollixed. Error name: " + e.name + ". Error message: " + e.message + " Line number = " +e.line);
      } // end try
    } // end function main
    // ================================================================================================
    // Dispatch
    // ================================================================================================
    main();

  • Is there a way to adjust crop borders on Crop and Straighten?

    I'm trying to use Photoshop CS3 to crop and straighten images of postage stamps.  E.g., place a bunch of stamps on the scanner bed and scan them as one image.  Then use Automate/Crop and Straighten Photos to create separate workspaces each with a single stamp image, cropped and rotated appropriately.  This almost works; the problem is it often crops the stamps too closely, cutting off the perforations.  The rotation is not always perfect either.  For example, for the above image I get:
    These two are pretty good except the perforation tips are trimmed off.
    This one is a disaster
    So I'm thinking if there were some way to specify how tightly the images are cropped, it might help solve the problem.  Any other suggestions?

    We now have a solution.
    http://forums.adobe.com/thread/778507?tstart=0

  • How do I edit my photos in iphoto? I want to straighten photos and remove some of the dead area.

    how do I edit my photos in iphoto? Specifically,I want to straighten photos and remove some of the dead (blank) area around the photos.

    tlhunnewell wrote:
    how do I edit my photos in iphoto? Specifically,I want to straighten photos and remove some of the dead (blank) area around the photos.
    First off it would be good to learn how to use iPhoto - editing is one of the most basic operations - what version of iPhoto do you have? Have you watched the videos and looked in Help?
    In general you select the photo can click edit - to straighten you use the "Straighten tool" - to remove areas around the photo you use the "crop tool"
    LN

  • Lightroom 4 and 5 my program constantly freezes while using the crop and straighten tool

    In both Lightroom 4 and 5 my program constantly freezes while using the crop and straighten tool with horizontal images. Im running Lightroom on a Quad-Core Intel Xeon Mac with 32 GB of memory with OS 10.8.4, this problem has gotten worse and worse to the point where the crop tool is unusable. Please help!

    Alright,
    no replies so far! Anyways, here's some more information which is leading me to the conclusion that the bug causing the effect described above is a combination of Apple's SMB implementation of Mavericks and the way Lightroom is actually using SMB network access:
    I did another trial by connecting a USB hard drive to the USB port of my router (Netgear). The connection is quite slow, but moving one of the folders in question (see my 1st post above) to the shared drive connected to the Router made Lightroom on my Windows machine to see the photos again, when I told Lightroom where to find the moved folder!
    Everything was working as expected, on the Windows machine again! Moving the folder back again to the Mac Mini fileshare was causing Lightroom on the PC to get blind again for the pictures trying to sync or import. However, accessing and modifying a photo was possible again, like it was before the trial. So it's only the sync and import function having a problem!
    I also did some trial in re-building ACLs and access rights on the file server with no luck. So there's got to be a functionality in sync and import of Lightroom which is using a certain SMB feature which is not supported by Apple's SMB implementation!
    Any thoughts or hints?
    Thanks!

Maybe you are looking for

  • Send a mail with ppt file as an attachment

    Hello,   I need to send an email which has a PPT file as an attachment. The file is on the hard drive of computer. I tried SO_DOCUMENT_REPOSITORY_MANAGER  FM. It is asking for a dialog box but I need to design a scheduler which will send this email.

  • Screen freezes after login on Lion OS X (intermittent)

    Ever since upgrading my MacBook Pro (purchased Apr-10) from Leopard to Lion I'm experiencing an intermittent problem where the screen freezes once a user has logged in. The problem only occurs when the machine is started from off and doesn't occur wh

  • Image stitching?

    Hi, I am working with a rectangular object but, due to various constraints, I need to take two squarish images and stich them together before processing the final image.  Searching this forum only shows a couple of threads from a while back so I was

  • Low Quality Capturing Video

    Hi I'm having some problems with the quality of the captured video obtained using JMF. I'm capturing and previewing video from a color camera (not saving it to disk) and some noise patterns are showing up. When I took a snapshot the noise is still th

  • Portal query %

    I couldn't solve portal query always needs "%" for searching. where can I put something like: select firstname from emp where firstname like "*"&[Enter the first name]&"*".....