Cropping a selection (JS CS3)
Hi -- I am developing a script in which a user chooses one of three predetermined sizes for an image from a dialog. This displays the crop selection but does not crop until the user has a chance to change the crop area (but not the size).
I can create the target crop selection with an action, but I cannot figure out how to crop to the selection area. The size will always be the same -- that I know how to enter in the script. But I do not know how to tell the script to crop the selected area.
Is there a way using the app.activeDocument.crop() command that I can have it crop to only the selected area?
Or is there a simple command I can put in the script to simply "crop" after the user changes the crop area and hits the OK button in my dialog. (Obviously, the user can simply doublelclick to set the crop -- but the OK button will do other things after the crop, and I am trying to eliminate as many clicks as possible.)
Any help would be greatly appreciated.
jmw107 wrote:
Hi -- I am developing a script in which a user chooses one of three predetermined sizes for an image from a dialog. This displays the crop selection but does not crop until the user has a chance to change the crop area (but not the size).
I can create the target crop selection with an action, but I cannot figure out how to crop to the selection area. The size will always be the same -- that I know how to enter in the script. But I do not know how to tell the script to crop the selected area.
I do not understand exactly your above description about user has a chance to change the crop area (but not the size). Do you mean they can move the position of the fixed crop size or the can position and size a part of the image to the crop area. If it is they can move and size part of the image into the crop area. I do that a different way. I set up a layer above the layer the image is on to act as a crop mask. Then I put the user into an menu File>Place dialog where the user select the image which Photoshop then open into a smart object layer below the cropping layer. The user is then in the Place interactive transform dialog where they size and position the part of the image the want within the cropping area. When they commit the place transform I delete the layer used as a cropping mask and add a layer mask to the smart object layer to mask all but the crop area. I don't actually Crop the layer after the process runs the image is still intact and a smart object layer with a cropping layer mask. The user can if the wish to tweak the image still without quality loss.
Similar Messages
-
Ai CS3, Win Xp Pro
I'm setting up business cards for two color printing and need crop marks around each card. Total of 4 cards, 7 cuts. In searching for Multiple Cropmarks on the internet, I'm finding articles that say it's not possible. However, I'm now looking at an Adobe livedocs help page that says:
Define and view additional crop areas
Select the Crop Area tool, and then do any of the following:
To create a new crop area, hold down Alt (Windows) or Option (Mac OS) and drag. Each crop area has a unique number in the upper-left corner.
To view all crop areas, press Alt (Windows) or Option (Mac OS).
To set a crop area as the active crop area, hold down Alt (Windows) or Option (Mac OS) and click the crop area you want active.
To rotate between crop areas, press Alt (Windows) or Option (Mac OS) and click an arrow key.
When I select the first cropped area with the crop tool, and attempt to copy it using the ALT key, a number 1 shows up in the upper left corner (ok so far). But as soon as I let go of the mouse button, the cropped area just moves to the place I've copied it to, and still has the number 1 in the corner. When I have the crop tool selected, and an area defined, I can press Enter and get a menu. There is an exclamation icon at the bottom signifying "Crop areas: 1", but there's no box to select multiple crops.
Am I SOL, or is there a trick to this?
Thanks,
SandoerOk, I've sort of answered my own question with a little more research.
For those that search this topic, here's what I discovered:
If you have several items that need to be cut, such as business cards, 8 or 10 up on an 8.5x11 sheet, you can
+create a stroked box at 2x3.5 (for business cards) around each card.
+one at a time, select a box and from the drop down menus select Filter>Create>Crop marks.
This will create marks that a printer can use for multiple cuts. -
Crop Area Tool - Illustrator CS3 (javascript)
Can Javascript use the Crop Area Tool in Illustrator CS3?
I am trying to create a crop area around the selected artwork.
I can select the artwork (path object). Then I want to use the preset: crop to selected artwork. Then save, and repeat for next file.
Is this possible using javascript?I don't know how far you have been up to with your code. I never really cropped the artwork by code, I only placed the crop marks using this code:
aiDocRef.cropBox = [-bld, docH+bld, docW+bld, -bld];
You could use the bounds of the selected graphics instead.
Since I've never scripted the printing in Ai, I cannot tell you how to crop while printing, but this might get you started. In CS4 they introduced multiple artboards, which requires different code for cropping, as far as I can see from the ref PDF.
cheers,
m. -
Can't crop arbitrary selected pages in combined PDF?
I'm getting weird behavior or seeing a bug when I try to crop selected pages in Acrobat XI.
Steps:
1. Click Create->Combine Files into a Single PDF
2. Add files and combine them as usual
3. Click on the Page Thumbnails view on the left
4. Control-click on a non-contiguous selection of thumbnails
5. Right-click and select Crop Pages. Fill in all the details and click OK.
Expected: Only the highlighted files are cropped.
Actual: All pages between the first selected page and the last selected page are cropped, even if they weren't selected. Pages before the first selected page and after the last selected page are not cropped.
Is there a way to override this behavior so only the selected pages are cropped? In the crop dialog, I can select all pages or a contiguous range (with the even and/or odd options), but no option for just "selection" like the rotate pages option has.
Thanks.
ChrisI should say that the crop pages function was never written to work with noncontinuous pages ... similar to other things like Extract Pages (at least in Acrobat X) which doesn't either, useful as it would be.
-
Feather a selection in CS3 gives unexpected reults
I have just upgraded to Photoshop CS3 from (CS2) and have discovered a very annoying problem with the feather command:
In previous versions (CS2 and earlier), if you select a part of an image, including borders, and then apply the feather command, then the selection edges along the borders were not feathered but the selection edge inside the picture (and bordering another part of the picture) was feathered. (The selection may be a rectangle or an irregular shape. In either case it is just the selection edge that is INSIDE the image that is feathered, and the selection edges along the border of the image are not feathered.)
Result: you get a rectangular selection with one edge feathered. (Or with a slightly irregular shape if the selection border within the image is not a straight line.)
Very useful if e.g. if you want to darken the sky in a high contrast sunny-day image.
Now to the problem:
In CS3 feathering occurs on the entire selection, including those parts of the selection that are along the edges of the image.
Result: you get an oval shape selected where all edges are feathered. And you cannot use that to darken e.g. the sky.
If this is hard to understand, here's a visual explanation:
http://westcoastimaging.blogspot.com/2008/01/fixing-photoshops-feather-command.html
or
http://tinyurl.com/6ryznh
(An excellent explanation. Follow the link at the bottom of that post
to request that Adobe should change back to the way feather used to
work, if you agree this is a problem!)
Very annoying that all of a sudden the feather command has changed.
Question:
1. Is there a fix so that it works "as before"?
2. Do you know of any other clever way (work-around) to do the same thing in PS CS3 in just a few clicks?Works for non-horizontal straight lines. Works for ellipses intersecting the boundaries. I'm not verifying your constraints.
A variation you might try: Before feathering, extend the selection beyond the border at least 2.7x the feather radius you intend to use. When you then modify the selection with a feather, there'll be no feathering at the border. -
Edit, Crop, Custom Select Everybloody time???
I must be missing something but in the last version of iPhoto I would double click a series of pics then hit edit. I would crop the pic to a custom size then click the arrow to save and go to the next pic to crop etc...
Now I have to hit the crop button everytime and everytime I have to pull down the menu to find custom then edit to my crop then hit the arrow for the next.
It then goes out of crop so I have to hit crop again and then pull down the custom again...
There must be a way to have it go to custom crop everytime I want to edit a large set of pics.
If not how can I go back to the last version of iPhoto?
thanks,
frankYou don't have to click on the Crop button each time. Just hit the "c" key. This video shows how quickly multiple crops of the same ratio can be accomplished. What you can see is the "c" key selected after the forward arrow key is selected.
Do you Twango?
TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance. iPhoto doesn't not have to be closed to run it, just idle.
I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file. -
Why are NEF files desaturating when selected in CS3 Bridge?
I recently started shooting in RAW but when I select the images in CS3 Bridge, they desaturate. It seems to only affect NEF files and not jpegs.
Read the link in this post. Should help you.
http://forums.adobe.com/thread/517584?tstart=0 -
Cropping glitch in Photoshop CS3
My cropping tool has ceased working in Photoshop CS3. When I try and crop an image to any size the canvas instantaneously reduced to 1 px in size. I have been using the cropping tool for this software for many years and now this glitch has occurred. Can anyone help me get rid of this glitch so the cropping tool works as it should again?
It might be that you have a small value like 1 px inserted into the width, height or resolution fields.
You can reset just the Crop Tool by right clicking on the Crop icon in the tool options bar and chose Reset Tool -
Crop a selection of video?
Does anyone know of a way to "selectively" crop a video? I don't mean cropping the overall size, say from 640x480 to 320x240. I mean like the way you can select and delete a part of a JPG file in Photoshop or other image editing software. I have various video editing apps and some can crop out black borders. But I want to cut away say the the left 100 pixels of a movie, leaving the rest intact. Any ideas? Thanks.
nÔÔdle--hëadMPEG Streamclip has cropping features.
In QuickTime Pro you can add a "mask" to any video track. Simple black and white image file sized to your dimensions. The white area of the image will allow the underlying video show through. -
Cropping a selected part of the image
hi all i have sample codes here for cropping an image...how do i crop out the image automatically after i release the mouse button? Can anyone pls help me cos i need to know how it works...
package MapWork;
// import packages
import java.awt.*;
import java.awt.event.*;
import javax.swing.JPanel;
import java.awt.Container;
public class CropImage extends JPanel
BorderLayout borderLayout1 = new BorderLayout();
private Image img;
Dimension d;
int x, y, width, height;
int startX = 0, startY = 0, endX = 100, endY = 100;
public CropImage()
super();
setPreferredSize(new Dimension(800,500));
try
jbInit();
catch(Exception ex)
ex.printStackTrace();
public void paintComponent(Graphics g)
/* Graphics2D is a class for rendering 2-dimensional shapes, text and
images in Java. It is used to construct the coordinates tranformations,
colour management, layout of text etc...*/
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)g;
g2d.drawImage(img, 0, 0, this);
// Math: to perform basic numeric operations. Math.min: return the
// smaller value between the 2 integers
int x = Math.min(startX,endX);
int y = Math.min(startY, endY);
// Math.abs: returns absolute value of a double value
int width = Math.abs(startX-endX);
int height = Math.abs(startY - endY);
// draw rectangle, specify the x & y axis and the width & height
g2d.drawRect(x, y, width, height);
//g2d.setColor(Color.red);
g2d.clipRect(x, y, width*2, height);
// copy the selected area to another frame
g2d.copyArea(x, y, width, height, width, height);
g2d.setClip(x, y, width, height);
private final Handler handler = new Handler();
private class Handler implements MouseListener, MouseMotionListener {
// occurs when mouse button is being pushed down
public void mousePressed(MouseEvent e)
setStartPoint(e.getPoint());
// Repaint method(): issues a request that a Component be redrawn within
// a specified time or as soon as possible if the time is left unspecified
repaint();
// mouseClicked: occurs when a mouse button is pressed and released
public void mouseClicked(MouseEvent e){}
// mouseExited:occurs when mouse cursor exits the unobscured part of
// component's space/geometry
public void mouseExited(MouseEvent e){}
// mouseEntered:occurs when mouse cursor enters the unobscured part of
// component's apace/geometry
public void mouseEntered(MouseEvent e){}
// mouseReleased:occurs when a mouse button is being released
public void mouseReleased(MouseEvent e)
setEndPoint(e.getPoint());
// Repaint method(): issues a request that a Component be redrawn within
// a specified time or as soon as possible if the time is left unspecified
repaint();
public void mouseMoved(MouseEvent e){}
public void mouseDragged(MouseEvent e)
setEndPoint(e.getPoint());
repaint();
public void setStartPoint(Point p)
startX = p.x;
startY = p.y;
public void setEndPoint(Point p)
endX = p.x;
endY = p.y;
private void jbInit()throws Exception
addMouseListener(handler);
addMouseMotionListener(handler);
img = Toolkit.getDefaultToolkit().getImage("koyomi.jpg");
}import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.*;
public class CropIt
public CropIt()
final ImageEasel imageEasel = new ImageEasel();
final ImageCropper cropper = new ImageCropper(imageEasel);
imageEasel.addMouseListener(cropper);
imageEasel.addMouseMotionListener(cropper);
// make up ui panel
final JButton
newClip = new JButton("new clip"),
reset = new JButton("reset"),
crop = new JButton("crop");
ActionListener l = new ActionListener()
public void actionPerformed(ActionEvent e)
JButton button = (JButton)e.getSource();
if(button == newClip)
cropper.enableNewClip();
if(button == reset)
imageEasel.reset();
if(button == crop)
imageEasel.cropImage();
newClip.addActionListener(l);
reset.addActionListener(l);
crop.addActionListener(l);
JPanel north = new JPanel();
north.add(newClip);
north.add(reset);
north.add(crop);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(north, "North");
f.getContentPane().add(new JScrollPane(imageEasel));
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
public static void main(String[] args)
new CropIt();
class ImageEasel extends JPanel
private BufferedImage image;
private Rectangle clip;
private Area mask;
private final int
CLIP_WIDTH = 100,
CLIP_HEIGHT = 100;
private boolean showClip, showCrop;
public ImageEasel()
loadImage();
clip = new Rectangle(0, 0, CLIP_WIDTH, CLIP_HEIGHT);
showClip = false;
showCrop = false;
protected void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
int w = getWidth();
int h = getHeight();
int imageWidth = image.getWidth();
int imageHeight = image.getHeight();
int x = (w - imageWidth)/2;
int y = (h - imageHeight)/2;
g2.drawImage(image, x, y, this);
if(showClip)
g2.setPaint(Color.red);
g2.draw(clip);
if(showCrop)
g2.setPaint(getBackground());
g2.fill(mask);
public void setNewClip(Point p)
if(!showClip && !showCrop)
clip.setLocation(p.x - CLIP_WIDTH/2, p.y - CLIP_HEIGHT/2);
showClip = true;
repaint();
public void reset()
showClip = false;
showCrop = false;
repaint();
public void moveClip(int x, int y)
clip.setLocation(x, y);
repaint();
public void cropImage()
if(showClip)
showClip = false;
showCrop = true;
mask = new Area(new Rectangle(0, 0, getWidth(), getHeight()));
Area clipArea = new Area(clip);
mask.subtract(clipArea);
repaint();
public Rectangle getClip()
return clip;
public boolean isClipVisible()
return showClip;
public Dimension getPreferredSize()
return new Dimension(image.getWidth(), image.getHeight());
private void loadImage()
String fileName = "images/cougar.jpg";
try
URL url = getClass().getResource(fileName);
image = ImageIO.read(url);
catch(MalformedURLException mue)
System.err.println("url: " + mue.getMessage());
catch(IOException ioe)
System.err.println("read: " + ioe.getMessage());
class ImageCropper extends MouseInputAdapter
private ImageEasel imageEasel;
private Point offset;
private boolean newClipEnabled, dragging;
public ImageCropper(ImageEasel ie)
imageEasel = ie;
offset = new Point();
newClipEnabled = false;
dragging = false;
public void mousePressed(MouseEvent e)
Point p = e.getPoint();
Rectangle r = imageEasel.getClip();
if(imageEasel.isClipVisible() && r.contains(p))
offset.x = p.x - r.x;
offset.y = p.y - r.y;
dragging = true;
if(newClipEnabled)
imageEasel.setNewClip(p);
newClipEnabled = false;
public void mouseReleased(MouseEvent e)
dragging = false;
public void mouseDragged(MouseEvent e)
if(dragging)
int x = e.getX() - offset.x;
int y = e.getY() - offset.y;
imageEasel.moveClip(x, y);
public void enableNewClip()
newClipEnabled = true;
} -
How to remove a crop from selected images
I need to create different crops on same image from one project, from project, to album, and smart folder i have one lot of crops and now i want to make other crops but the images in the project and blue folders have all the new crops too, how do i get back to a folder with no crops, I'd like to keep the retouches to these images though, i think i should have started differenttl?
Help appreciated
ThanksNot clear on what you have, but to remove the crop on any given image; you can either clear the check mark in the crop brick or remove the crop adjustment altogether. The crop brick shows in the Adjustment Inspector when you crop an image:
http://documentation.apple.com/en/aperture/usermanual/#chapter=17%26section=10
For more info on the crop tool:
http://documentation.apple.com/en/aperture/usermanual/#chapter=18%26section=6%26 hash=apple_ref:doc:uid:Aperture-UserManual-91292MAD-1013949
Note - typically, you would create a new version for additional cropped versions of the image. You can use the 'New Version from Master' command (control-click or right-click on image for the menu). This will create a new version to work on that is un-cropped whether the current version is cropped or not, but will not include any other adjustments either. -
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
cheersThis 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(); -
When i crop a video using FCE, how can i export just the selection?
When using the cropping tool with FCE 4, say i just crop out a single square from near the top of the video. if i were to export this video now, the new video would consist of the cropped out selection surrounded by black. is there anyway i can export the cropped out selection without the black? i'm not looking to rescale the image, just to remove the selection at it's original size without all the black around it.
FCE's a fixed-resolution editor and there's no way to export at the resolution of your cropped image unless it matches one of the sequence presets. In FCP you could set a custom resolution and export as that.
-
How to crop selected area?
Is it possible to crop the selected area of a page, because now if i go to Tools>Pages>Crop it can only crop the area that is outside the selected area?
Thanks!This delete the content inside the selected area but doesn't crop the area, but i guess i could use it.
How can i add content from the clipboard and retain the format? I am trying to create pdf file with content that i copy from html pages but when i paste the text it paste it as plain text, doesn't keep the format. -
I was trying out the crop tool on Illustrator CS3 on Windows XP. I can access other tools but when I use the select tools it keeps returning to the crop tool. The file is a pdf opened in Illustrator (raster). Vector files are not a problem -
When I go back to the original pdf and open it the crop tool still appears and I get a horizontal band already selected. This band an be deleted or resized but I cannot access the area I want to use.
How do I get the crop tool off?Frustrating isn't the word.
I reported this through a previous post (much the same as you are experiencing).
crop not keeping to ratio
It was ok in LR3 and is ok in LR5 (I think)
so they have fixed the bug, but where does that leave the LR4.4 users ??
Upgrade to LR5 ?
Surely there should be a LR4.4 bug fix that can be downloaded instead of yet another purchase to upgrade.
Maybe you are looking for
-
Error while adding Incoming Excise Invoice
Hi Experts, I am facing 1 problem while adding Incoming Excise Invoice & A/P invoice. The error msg is:- No matching records found 'G/L Accounts' (OACT) (ODBC -2028) [Message 131-183] What might be reasons Vendor account is correctly defined. Regar
-
I'm trying to download java on my Mac machine but the software update doesn't show me anything. Please advise what I should do to get the application.
-
NI_TPC_WF.​lvlib error
Hi I am using a TPC-2212 and I keep getting inconsistent errors. I keep having network difficulty with the touchpanel to a cRIO 9074. One thing that pops up once in a while on the touch panel is a NI_TPC_WF.lvlib error, which claims I don't have perm
-
IOS 8 3G to 2G toggle missing :(( please fix it
Hi, I just upgraded my iPhone 5s 16GB to iOS 8. Everything seems ok but for one problem. There used to be a "Enable 3G" toggle in the cellular data menu. It is no longer present and has been replaced by "Enable LTE". Charge quickly empties please hel
-
Help upgrading from Tiger to Leopard
I need to upgrade from Tiger to Leopard for Quickbooks 2009; can you point me to some resources that will walk me through the process (and point out any pitfalls)? Also is the product that outfits like Amazon or Buy.com are selling what I need to do