Article View: adobe.photoshop.scripting
Article #46Re: Action that resizes to specific uncompressed size? Please help!
From: Paul_R
Date: Tue, 31 Mar 2009 16:16
Date: Tue, 31 Mar 2009 16:16
48 lines
1780 bytes
1780 bytes
I wonder if this is what you are looking for?
This was writtem by Mike Hale.
var SizeOfFile = prompt("Please Enter Size In Megabytes",48)
if (SizeOfFile > 0) resizeToMB( SizeOfFile );
function resizeToMB( size_in_MB ) {
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 final_size = ( 1024 * 1024 * size_in_MB ) / channel_count;
var image_bytes = width_pixels * height_pixels;
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_dpi = activeDocument.resolution;
if ( image_scale > 1 ) {
activeDocument.resizeImage( final_width, final_height, final_dpi, ResampleMethod.BICUBICSMOOTHER );
} else {
activeDocument.resizeImage( final_width, final_height, final_dpi, ResampleMethod.BICUBICSHARPER );
}
preferences.rulerUnits = current_units;
}
Technical Details
Message-ID:
<59b87301.1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.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!newshub.sdsu.edu!webcrossing Newsgroups: adobe.photoshop.scripting Subject: Re: Action that resizes to specific uncompressed size? Please help! Message-ID: <59b87301.1@webcrossing.la2eafNXanI> Date: Tue, 31 Mar 2009 09:16:45 -0700 References: <59b87301.-1@webcrossing.la2eafNXanI> Lines: 28 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit