software
The following pieces of software are made freely available to the public for use as per their attached or associated licenses.
This is a Photoshop CS Javascript that allows you to automate the resizing and cropping of images in Photoshop without worrying about the orientation or aspect ratio (proportions) of the image. It will resize and crop an image to the exact dimensions that you specify. These features are especially useful when you want to automate the process on a number of images by adding it to an action set.
Note that many people have mentioned the "Fit Image" command which merely resizes an image to fit within a frame of a certain proportion, but does not actually crop an image to what you want as the final result.
You can find examples of how to use the script near the end of this page
Please provide any feedback via email to tech @ this-domain
resizerlite.jsx is released under a liberal BSD-style license which enables you to add, modify, and distribute the code however you want, whether privately or commerically so long as the product retains the original copyright information and acknowledgements.
Right click on a link and "Save As" into a location where you can easily get to.
version 0.1.3a (14 Sept 2004 Photoshop CS).
version 0.1.4a (19 Nov 2004 Photoshop CS).
version 0.2.1a (30 April 2005 for Photoshop CS2).
version 0.2.2a (27 May 2007 for CS3, should be CS2 compatible).
LATEST version 0.3 (14 June 2010 for CS5, should be CS3 compatible).
- Resize and Crop to any dimension (currently only centre-cropped).
- Resize to Fit Image within a defined dimension, specifying long side only and short side resized proportionally, or specifying short side only and long side resized proportionally.
- Add EXIF information (or any other type of text) from RAW, TIFF, and JPEG files. In v2.2: You can choose any font that's on your system for the text. You can position the text in any part around the border (almost).
- Add Proof text watermark to image.
- Add matting border.
- Reposition image so that a drop shadow effect can be applied - for thumbnail purposes.
- Auto rotation of image to landscape or portrait.
- Watermark your photo with any image. (v2.1+)
I've attempted to make the script as simple to use as possible, so hopefully things should be obvious upfront. Nevertheless, this instruction set is meant to help you fine tune the script to your desired needs and also shows a few examples on the uses of the script.
You can edit the script with any text editor available on your system, such as Notepad. Simply open it up in the editor and change the required fields to meet your needs. Once you have finished editing the script, you should save it with an appropriate filename, such as "6x4x250_bordered.jsx" to indicate a script that resizes the photo to 6x4" at 250dpi and with a border.
To run the script in Photoshop, have an image opened and go to
File->Scripts->Browse to locate your script.
Photoshop will run it immediately after opening the script.
If you want the script to appear in Photoshops menu (in File->Scripts area)
automatically, copy the script to the Photoshop/Presets/Scripts folder
(eg C:\Program Files\Adobe\Adobe Photoshop CS3\Presets\Scripts).
1.
Start by going to the section that has MODIFY THIS SECTION ONLY.
Anything that is enclosed within /* and */ are comments and not processed by the
scripting engine.
You can then modify any of the values that start with var, ie units, long_side,
short_side, etc. The types of values you can change them to are shown after the
example below.
/* * MODIFY THIS SECTION ONLY *********************** * * Change the following parameters to what you want. * Only change the values after the "=" sign. * ... */ var units = INCHES; var long_side = 4; var short_side = 6; var dpi = 250; var orientation = ORIG; var border = 0.25; var dropshadow = 0; var textedge = border/2; var dateformat = MDY; // format for date timestamp // leave color_profile as "" if no profile change desired. var color_profile = "sRGB IEC61966-2.1";
units
Specify the output units you are working in. The valid values are INCHES, CM, and PIXELS. Apart from the dropshadow value which is measured in pixels (I'll fix this up in due time), every other dimension value is measured in the units specified here.long_side
Put down how long you want the longest side of the photo to be resized to.
If you put down 0 (zero), then the photo will be resized proportionally to the short_side.
If both long_side and short_side are 0 (zero), then the photo is not resized.
If both long_side and short_side are specified, then the photo is resized and cropped to that area.short_side
Similar to the long_side parameter, this specifies how large the shortest side of the photo should be. You can leave this as 0 (zero) to resize proportionally to the long_side of the photo.dpi
Change this to the dots-per-inch resolution of the output device. For example, for viewing on the monitor only, 72 is sufficient. For printing, you should set it to 250 or 300. Note that DPI is really only relevant forunitsof INCHES or CM.orientation
Originally, this was designed to rotate the image into the portrait or landscape position because, back then, a large number of print houses required you to set the orientation of the photo explicitly. Their machines did not have the capability to print the photo in the correct way without it. Nowadays, you can leave your photo in any orientation and the printer is smart enough to do the right thing.
The valid values for orientation areORIG,LANDSCAPE, orPORTRAIT.border
If you'd like the script to automatically add a border to the photo, you can specify how large that border is. The border colour by default is white. How this works is the photo is copied onto a new layer and the background layer is cleared out. The photo layer is then masked with a border.dropshadow
(in PIXELS only) The dropshadow feature is only useful if you plan to create thumbnails with the script and want to add enough room for a drop shadow to appear under the thumbnail.
The script does not actually add a dropshadow effect to the image, but only creates a duplicate layer, resizes and moves the photo to the top left position. You need to add the dropshadow effect to the layer yourself after the script has ran.textedge
If you plan on having text written around the border of the image, thetextedgevalue tells the script how far from the edge of the image to print the text. The default value ofborder/2puts the text right in the middle of the border.dateformat
Because of internationalisation of dates, I've added the ability to specify the local date format of your country. For US format, useMDY, and for most other countries, useDMY.color_profile
If you want to automatically convert the image to a particular color profile then set this value. The full name must be provided (exactly as it appears in the profiles dropdown in Photoshop).
2.
Go to the Personal Signature Overlay section. Changing this section
allows you to add your own customised watermark onto the image. The watermark can
be any type of image that Photoshop is able to open, ie, JPG, PNG, PSD, etc.
If you want your own logo as the watermark, I recommend that you create it as a
two layer PSD, with the top layer being the logo. This way, you can have transparent
areas around the logo not appear in the watermark.
/* * Personal Signature overlay * * - signature_file = specify the full filename of ... * ... */ var signature_file = ""; // signature not used var signature_position = BOTTOM_EDGE | RIGHT_CORNER; var signature_width = 1; var signature_height = 0; var signature_opacity = 50.0; var signature_gutter = border + 0.1;
signature_file
The full filename of your watermark image file. This includes the full drive letter and directories for the file. The directory path must be separated with a forward slash "/". For example, "C:/Photos/MyLogo/Logo.psd" for Windows.signature_position
The location to put the watermark over the image.
For vertical position, the valid values areTOP_EDGE,MIDDLE, andBOTTOM_EDGE.
For horizontal position, the valid values areLEFT_CORNER,CENTER, andRIGHT_CORNER.
The vertical and horizontal position are combined with a "|" (pipe) character. In the example above,BOTTOM_EDGE | RIGHT_CORNERputs the watermark at the lower right hand corner of the image.signature_width, signature_height
The width and height that you want to resize the watermark to. If only one of the dimension is specified, the other is resized proportionally. They are measured in the same unit as specified by theunitsparameter.signature_opacity
The opacity of the watermark...signature_gutter
Specifies how far from the edge of the image that the watermark's edge should be.
3.
The script allows you to add a large number of text fields to the image at
many of the positions around the border. Each text field is specified as
an element in the text_fields array. While it might look
daunting to modify at first, once you understand what the entries are, you
should be able to customise them yourself.
If you don't want to have any text added to the image, simply change the text_fields to:
var text_fields = "";
var text_fields = new Array (
new Array(
"TEXT",
"FONT",
FONT SIZE,
PLACEMENT
),
new Array(
"\xA9 Copyright - text field 1", // text
"Arial", // font
6, // size
TOP_EDGE | LEFT_CORNER | TEXT_ALIGN_BORDER // align
),
...
);
A text field consists of four entries and wrapped in an Array. The
example in the script will draw text at almost every corner of the image. You can
delete text field entry in the text_fields array if you don't want that many.
The entries in each text field consist of:
- the text string itself, which can be customised with EXIF information (discussed below)
- the font for the text field, exactly as presented in the drop down list of fonts in Photoshop
- the size of text, in points
- the placement of the text, combinations of horizontal and vertical positions:
TOP_EDGE,MIDDLE,BOTTOM_EDGE,LEFT_CORNER,CENTER, andRIGHT_EDGE. There is a specialTEXT_ALIGN_BORDERoption which places the text aligned to the sides of the border frame (away from the full edge of whole the image).
The script provides the flexibility of adding EXIF information to the text fields by looking for special character combinations that are prefixed with a %.
For example, if you wanted to have the filename shown and the date that the photo
was taken, you can have a text string of
"%f, shot on %D".
This will result in a line such as this being printed on the image:
IMG_3444, shot on 30/03/2007
The full set of accepted fields that can be added to your custom text includes:
%f - filename %F - filename with extension %d - date in YYYY/mm/dd format %D - date in dd/mm/YYYY (DMY) or mm/dd/YYYY (MDY) format %h - time in hh:mm AM/PM, 12 hour format %H - time in HH:MM, 24 hour format %i - ISO %a - aperture (f/stop) %s - speed (1/n seconds) %l - lens focal length (in mm) %b - camera Make %c - camera Model %% - print % character
4. The final feature of the script is the ability to stamp a Proof text right in the center of the image. The proof text can be rotated counter-clockwise to any number of degrees. The opacity can also be changed if desired. The values should be straight forward to chanage if you want Proof stamping.
var proof_text = ""; var proof_font = "Arial"; var proof_text_size = 60; var proof_text_rotate = 10; var proof_text_opacity = 50.0;
I'm going to use the following photo as a starting point. It was taken with an SLR, so the proportions are 3:2 ratio, and it's 8 Megapixels in size.

I change the script to have following parameters:
var units = PIXELS; var long_side = 640; var short_side = 480; var dpi = 72; var orientation = ORIG; var border = 30; var dropshadow = 0; var textedge = border/2; var dateformat = MDY; var text_fields = "";
As you can see from the resulting image below, resizing the photo to 640x480 will crop it a little because the SLR photo is actually wider in proportion than 640x480. Since we specified both the long side and short side, the script will perform an automatic cropping of the photo to fit within the dimensions. It doesn't squish them down into proportions because the photo would end up looking distorted in one direction.

I create the following logo to be used as a watermark. It's a two layer Photoshop image with an empty background.

I update the script to enable a watermark. Note that since I have specified that the units be in PIXELS, all my measurements are also in PIXELS
var signature_file = "C:/temp/dmsx.psd"; var signature_position = BOTTOM_EDGE | CENTER; var signature_width = 200; var signature_height = 0; var signature_opacity = 70.0; var signature_gutter = border + 5;
The photo then has my logo centered at the bottom

I want to put a heading with the photo's name and date at the top left, and my name at the center bottom of the photo. I basically modify the text_fields array to contain two text entries:
var text_fields = new Array (
new Array(
"%f, %D", // text
"Arial", // font
12, // size
TOP_EDGE | LEFT_CORNER | TEXT_ALIGN_BORDER // align
),
new Array(
"LEON DANG", // text
"Georgia", // font
16, // size
BOTTOM_EDGE | CENTER // align
),
);

v1.4a
- Unlimited text fields (stored in an array)
- Vertical text alignment
v2.1a
- Same as 1.4a
- New: Apply your own custom signature!!!
- Image layer now has a mask applied rather than clearing out the cropping area
- Photoshop CS2 support ONLY, will not work with CS1
- There is a bug in the first release of Photoshop CS2 regarding the doc.resizeImage() function which doesn't seem to be able to resize the image when the units isn't in PIXELS. Adobe, fix this bug up!
v2.2a
- Same as 2.1a
- New: Support for PS-CS3 (should also be compatible with CS2)
- Watermark/signature graphics file can be any flat image or a multilayer PSD (only top layer is used).
- Correctly uses the fonts on your system for text (automatically translates the names shown in the Font drop down to the Postscript name expected by Photoshop).
- Photoshop CS2/CS3 support ONLY, will not work with CS1