PhotoshopForums.com Home
Navigate Contact FAQ Search Members
Want to create a smart image size action.
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation
Goto page 1, 2  Next
 See a User Guidelines violation? Please contact us.
Author Message

ryanh

Joined: 16 Aug 2010
Posts: 13



PostPosted: Tue Aug 17, 2010 12:03 pm    Post subject: Want to create a smart image size action. Reply with quote

I work at an e-comm website in the photo production dept. So I am using photoshop to make adjustments to a large amount of images, sometimes thousands.
I want to create an action that will only res down images that are greater than a specified size(say 2000x2000 px). If they are smaller than the specified size, I want the action to skip it and go on to the next image.
This way, I won't have to sort through a large number of images that are a mix of images sizes. Is this possible in photoshop?
View user's profile Send private message

Paul R

Joined: 06 Apr 2010
Posts: 57



PostPosted: Tue Aug 17, 2010 1:09 pm    Post subject: Reply with quote

Have a look at this thread....
http://forums.adobe.com/thread/693986?tstart=0
View user's profile Send private message

ryanh

Joined: 16 Aug 2010
Posts: 13



PostPosted: Tue Aug 17, 2010 1:20 pm    Post subject: Reply with quote

Thanks Paul R. this info helped. I am pretty unversed in the scripting, so I could not figure out where the people were inserting the scripts in order to run their action. more words of wisdom please.
_________________
Image production tech
Photoshop CS3
Mac OS 10.5.8
View user's profile Send private message

Paul R

Joined: 06 Apr 2010
Posts: 57



PostPosted: Tue Aug 17, 2010 1:33 pm    Post subject: Reply with quote

This script is run from ExtendScript Toolkit this program is the Integrated Development Enviroment that get installed with Photoshop.
This can be found in the following folder:-
PC: C:\Program Files\Adobe\Adobe Utilities
MAC: <hard drive>/Applications/Utilities/Adobe Utilities

What this code does is to look for all JPG's that are 1000 pixels or greater on the longest side and resize them to 500 pixels on the longest side.
It overwrites the existing files! and no metadata is retained.
All this is done in Bridge

Code:

#target bridge
var thumbs = app.document.getSelection("jpg");
alert("Checking "+ thumbs.length + " files");
var jpgs = 0;
for(var a in thumbs){
var md = thumbs[a].synchronousMetadata;
var t= new Thumbnail(thumbs[a]);
if(Math.max(t.core.quickMetadata.width,t.core.quickMetadata.height)>=1000){ //1000 is the pixels size it is checking for
jpgs++;
md.namespace = "http://ns.adobe.com/tiff/1.0/";
var orientation = md.Orientation.replace(/(\w+)(\s+)(.)(\d+)(.)/,"$3$4");
if(orientation == 'Normal') orientation =0;
var bm = new BitmapData(thumbs[a].spec);
bm = bm.rotate(orientation);
bm = bm.resize(500,BitmapData.bicubicSharper); //500 is the new size
bm.exportTo(new File(thumbs[a].spec),80); //80 is the quality
     }
}
alert(jpgs + " JPEGs have been modified");


Hope this helps.
View user's profile Send private message

ryanh

Joined: 16 Aug 2010
Posts: 13



PostPosted: Tue Aug 17, 2010 1:36 pm    Post subject: Reply with quote

Yes it totally helps. Can i incorporate this script into a bridge menu? or do I need to open the script toolkit app each time?
Thanks.

_________________
Image production tech
Photoshop CS3
Mac OS 10.5.8
View user's profile Send private message

Paul R

Joined: 06 Apr 2010
Posts: 57



PostPosted: Tue Aug 17, 2010 1:54 pm    Post subject: Reply with quote

Yes, to install the script (Make sure you amend the sizes to suit!) start Bridge > Edit > Preferences - Startup Scripts
Click the "Reveal My Startup Scripts" button (CS5) or the "Reveal" button in earllier versions, this will open the folder where the script should be put.
Once copied to the folder, re-start Bridge and accept the new script.
To use : You will find the command in the Mouse Right Click Menu /control click on a Mac. "Resize JPGs"
Code:

#target bridge   
if( BridgeTalk.appName == "bridge" ) { 
resizeJPGS = new MenuElement("command", "Resize JPGs", "at the end of Thumbnail");
}
resizeJPGS.onSelect = function () {
     resizeJPG();
     }
function resizeJPG(){
var thumbs = app.document.getSelection("jpg");
alert("Checking "+ thumbs.length + " files");
var jpgs = 0;
for(var a in thumbs){
var md = thumbs[a].synchronousMetadata;
var t= new Thumbnail(thumbs[a]);
if(Math.max(t.core.quickMetadata.width,t.core.quickMetadata.height)>=1000){ //1000 is the pixels size it is checking for
jpgs++;
md.namespace = "http://ns.adobe.com/tiff/1.0/";
var orientation = md.Orientation.replace(/(\w+)(\s+)(.)(\d+)(.)/,"$3$4");
if(orientation == 'Normal') orientation =0;
var bm = new BitmapData(thumbs[a].spec);
bm = bm.rotate(orientation);
bm = bm.resize(500,BitmapData.bicubicSharper); //500 is the new size
bm.exportTo(new File(thumbs[a].spec),80); //80 is the quality
     }
}
alert(jpgs + " JPEGs have been modified");
}

Make sure you do a test first!
//////////////////////////////////

If you want do do sub-folders you can use:
View > Show Items from Subfolders
View user's profile Send private message

ryanh

Joined: 16 Aug 2010
Posts: 13



PostPosted: Tue Aug 17, 2010 2:06 pm    Post subject: Reply with quote

Ok, cool. Got the script in the startup folder and enabled. But it does not show up in the right click menu for me. Thoughts?
_________________
Image production tech
Photoshop CS3
Mac OS 10.5.8
View user's profile Send private message

Paul R

Joined: 06 Apr 2010
Posts: 57



PostPosted: Tue Aug 17, 2010 2:18 pm    Post subject: Reply with quote

It should work, but lets try putting it in its own menu.
Please replace the script with this code..
You should then see a new Menu on the top bar "JPG Resize"
Code:

#target bridge   
if( BridgeTalk.appName == "bridge" ) { 
var newMenu = new MenuElement( "menu", "JPG Resize", "after Help", "JPG-Resize" );
var newCommand = new MenuElement( "command",  "Resize JPGs", "at the end of JPG-Resize" , "xx1x" );
}

newCommand.onSelect = function () {
     resizeJPG();
     }
function resizeJPG(){
var thumbs = app.document.getSelection("jpg");
alert("Checking "+ thumbs.length + " files");
var jpgs = 0;
for(var a in thumbs){
var md = thumbs[a].synchronousMetadata;
var t= new Thumbnail(thumbs[a]);
if(Math.max(t.core.quickMetadata.width,t.core.quickMetadata.height)>=1000){ //1000 is the pixels size it is checking for
jpgs++;
md.namespace = "http://ns.adobe.com/tiff/1.0/";
var orientation = md.Orientation.replace(/(\w+)(\s+)(.)(\d+)(.)/,"$3$4");
if(orientation == 'Normal') orientation =0;
var bm = new BitmapData(thumbs[a].spec);
bm = bm.rotate(orientation);
bm = bm.resize(500,BitmapData.bicubicSharper); //500 is the new size
bm.exportTo(new File(thumbs[a].spec),80); //80 is the quality
     }
}
alert(jpgs + " JPEGs have been modified");
}
View user's profile Send private message

ryanh

Joined: 16 Aug 2010
Posts: 13



PostPosted: Tue Aug 17, 2010 2:39 pm    Post subject: Reply with quote

We are getting there Paul R. Your knowledge amazes me. I got the script in the menu. when I run it I says it is checking the files, but then does not make any changes to the image dimensions. what is next?
_________________
Image production tech
Photoshop CS3
Mac OS 10.5.8
View user's profile Send private message

ryanh

Joined: 16 Aug 2010
Posts: 13



PostPosted: Tue Aug 17, 2010 2:42 pm    Post subject: Reply with quote

Ok, I just got it to work by selecting the files in the folder rather than just having the folder I want scanned open in bridge. That sound right?
Can this script be used in cs3 bridge? a coworker is on cs3

_________________
Image production tech
Photoshop CS3
Mac OS 10.5.8
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Contact - User Guidelines >

Copyright © 2003-2016. PhotoshopForums.com, iFroggy Network. All Rights Reserved.
Powered by phpBB © phpBB Group. phpBB SEO. Privacy Policy.
We are in no way affiliated with Adobe. Photoshop, Adobe and related marks are registered trademarks of Adobe.
PhotoshopForums.com