Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

scripting to print 4x6

New Here ,
May 14, 2008 May 14, 2008
Many of my photos are cropped to square or panoramic formats. When I take the photos to the printer to get 4x6 prints, anything that is not 4x6 (such as a square or panoramic image) gets cropped down to fit and I lose a bunch of the image.

I've worked around this by creating some photoshop actions that add white space to either the bottom or side of an image, so that the resulting image is 4x6 format (or 2:3 aspect ratio). The prints come back with white space that I trim on my paper trimmer at home.

However, it's a pain in the butt to have to sort the images into verticals and horizontals to choose which action to run. I am trying to write a simple script to run one action if the image width/height>1.5, and a different action if the width/height<1.5.

Can anyone please help?
TOPICS
Actions and scripting
658
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
May 16, 2008 May 16, 2008
Im a Scripting-rookie myself but if its only the conditional clause this might do it:

var myDoc = app.activeDocument
var x2 = (myDoc.width);
var y2 = (myDoc.height);
if (x2/y2 < 1.5) {
//enter your intended operation here

}
if (x2/y2 > 1.5) {
//enter your intended operation here

}

The Canvas-resizing would have to be done in the Script as well though, I guess, and not as an Action.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 16, 2008 May 16, 2008
Well, I hadnt given it enough thought ... this should work though:
var myDoc = app.activeDocument;
// define the variables
var myDoc = app.activeDocument;
var x2 = (myDoc.width);
var y2 = (myDoc.height);
// for landscape
if (x2 > y2) {
if (x2/y2 > 1.5) {
myDoc.resizeCanvas (x2, x2/1.5, AnchorPosition.MIDDLECENTER)
}
if (x2/y2 < 1.5) {
myDoc.resizeCanvas (y2*1.5, y2, AnchorPosition.MIDDLECENTER)
}
}

// for portrait
if (x2 < y2) {
if (y2/x2 > 1.5) {
myDoc.resizeCanvas (y2/1.5, y2, AnchorPosition.MIDDLECENTER)
}
if (y2/x2 < 1.5) {
myDoc.resizeCanvas (x2, x2*1.5, AnchorPosition.MIDDLECENTER)
}
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 16, 2008 May 16, 2008
Ok here's my version, it also checks for square image.

#target photoshop
var doc = app.activeDocument;
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
var x = doc.width.value;
var y = doc.height.value;
if (x > y) {
doc.resizeCanvas (x, x/1.5, AnchorPosition.MIDDLECENTER);
}
if (x < y) {
doc.resizeCanvas (y/1.5, y, AnchorPosition.MIDDLECENTER);
}
if (x == y) {
doc.resizeCanvas (x*1.5, y, AnchorPosition.MIDDLECENTER);
}
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 16, 2008 May 16, 2008
pgenesis9,

I have a utility script that addresses this specifically at: http://www.rags-int-inc.com/PhotoTechStuff/PscsScripts/.

Cheers, Rags :-)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 20, 2008 May 20, 2008
Perfect! Thanks to everyone for your help
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 20, 2008 May 20, 2008
LATEST
Looks like this will work for a panoramic image. But if you have an image that is in between a square shape and a 2x3 aspect shape, this script will crop, no?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines