Article View: adobe.photoshop.scripting
Article #77Re: Action that resizes to specific uncompressed size? Please help!
From: Paul_R
Date: Fri, 03 Apr 2009 13:01
Date: Fri, 03 Apr 2009 13:01
50 lines
1770 bytes
1770 bytes
Here is the first one...
if(documents.length) resizeToFiftyMeg();
function resizeToFiftyMeg(){
var SizeOfFile = 50; //This is the actual size required.
var current_units = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
var width_pixels = activeDocument.width;
var height_pixels = activeDocument.height;
var channel_count = activeDocument.channels.length;
var image_bytes = width_pixels * height_pixels;
var actual =((image_bytes/1024/1024)*channel_count).toFixed(2);
if(actual >= SizeOfFile) return;
var final_size = ( 1024 * 1024 * SizeOfFile ) / channel_count;
var image_scale = Math.sqrt( final_size/ image_bytes );
var final_width = width_pixels * image_scale;
var final_height = height_pixels * image_scale;
var final_ppi = activeDocument.resolution;
activeDocument.resizeImage( final_width, final_height, final_ppi, ResampleMethod.BICUBICSMOOTHER );
preferences.rulerUnits = current_units;
}
and the second..
if(activeDocument.pathItems.length){
app.activeDocument.pathItems.removeAll();
}
Technical Details
Message-ID:
<59b87301.15@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeed.news2me.com!newshub.sdsu.edu!webcrossingReferences:
<59b87301.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,21e37c569c4141d3 X-Google-Attributes: gidf5839,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Paul_R@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeed.news2me.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.photoshop.scripting Subject: Re: Action that resizes to specific uncompressed size? Please help! Message-ID: <59b87301.15@webcrossing.la2eafNXanI> Date: Fri, 3 Apr 2009 06:01:34 -0700 References: <59b87301.-1@webcrossing.la2eafNXanI> Lines: 29 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit