Skip to main content
Participant
August 7, 2008
Question

Reduce file dimension size by specified amount

  • August 7, 2008
  • 7 replies
  • 866 views
we are trying to create an action or script to reduce images by .0625" from all 4 sides of artwork we receive from our customers. Anyone have any ideas?
This topic has been closed for replies.

7 replies

Participant
August 15, 2008
Paul, would you mind emailing me directly? barry @ m3printing.com
Paul Riggott
Inspiring
August 10, 2008
What it does is, change the document to pixels
app.preferences.rulerUnits = Units.PIXELS;
Therefore 1 inch is equal to the resolution of the document.
var res = activeDocument.resolution;
here res is now 1 inch
Maths is now done res/8 = ( 1" / 8 ) = cropFactor
This is then deducted from the original width
var Width = activeDocument.width.value - cropFactor;
and the original height.
var Height = activeDocument.height.value - cropFactor;
These values are sent to the resize function.
Participant
August 10, 2008
Thanks Paul! Ok two quick questions:

#1 why when we run the script it doesnt take off a total of .0625? The length of an image that I resized was 4.25, but after I ran the script it brought the size down to 4.127.

#2 Where in the script does it define the amount that the image needs to be resized?
Paul Riggott
Inspiring
August 10, 2008
Sorry about that, this should do it now.
NB: Resizing will not constrain proportions unless the artwork is SQUARE.



#target photoshop

var startRulerUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

var res = activeDocument.resolution;

var cropFactor = res/8;

var Width = activeDocument.width.value - cropFactor;

var Height = activeDocument.height.value - cropFactor;

resize(Width,Height);

app.preferences.rulerUnits = startRulerUnits;



function resize(Width,Height) {

var ad = new ActionDescriptor();

ad.putUnitDouble( app.charIDToTypeID('Wdth'), app.charIDToTypeID('#Pxl'), Width );

ad.putUnitDouble( app.charIDToTypeID('Hght'), app.charIDToTypeID('#Pxl'), Height );

ad.putEnumerated( app.charIDToTypeID('Intr'), app.charIDToTypeID('Intp'), app.stringIDToTypeID('bicubicSharper') );

executeAction( app.charIDToTypeID('ImgS'), ad, DialogModes.NO );

};

Participant
August 10, 2008
thanks guys, but that doesnt actually solve the problem. We do not want to crop the image...we need to RESIZE it. We have to keep the image intact, but just resize it down .0625 on all 4 sides.
MarkWalsh
Inspiring
August 7, 2008
A simple action would work as well.

Just create a new action, choose 'canvas size', and make sure that 'Relative' is checked, and enter -.125 inches into both boxes.
Paul Riggott
Inspiring
August 7, 2008
This should be close....



#target photoshop

var startRulerUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

var res = activeDocument.resolution;

var cropFactor = res/8;

var Width = activeDocument.width.value - cropFactor;

var Height = activeDocument.height.value - cropFactor;

app.activeDocument.resizeCanvas(Width, Height, AnchorPosition.MIDDLECENTER);

app.preferences.rulerUnits = startRulerUnits;