Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
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;
}
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
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;
}
if(activeDocument.pathItems.length){
app.activeDocument.pathItems.removeAll();
}
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
Hi guys
I started this thread back in April and I've been using the scripts developed back then eagerly.
I have tried to combine the scripts with some actions and now I am getting some strange behaviour where the script opens the preferences for units and rulers. What seems to be the problem? The script looks like this:
var SizeOfFile = 50
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;
}
Kind regards,
Daniel Laflor
Copiar vínculo al Portapapeles
Copiado
By the way this is what the whole action looks like:
Any suggestions?
Copiar vínculo al Portapapeles
Copiado
I'm not sure what is going on, but here is a version that does not change the rulerIUnit.
var SizeOfFile = 50
if (SizeOfFile > 0) resizeToMB( SizeOfFile );
function resizeToMB( size_in_MB ) {
var width_pixels = activeDocument.width.as('px');
var height_pixels = activeDocument.height.as('px');
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( new UnitValue(final_width,'px'), new UnitValue(final_height,'px'), final_dpi, ResampleMethod.BICUBICSMOOTHER );
} else {
activeDocument.resizeImage( new UnitValue(final_width,'px'), new UnitValue(final_height,'px'), final_dpi, ResampleMethod.BICUBICSHARPER );
}
}
Copiar vínculo al Portapapeles
Copiado
It still does the same weird thing with your script.
I experimented and removed the resize script from the action set and everything else runs smoothly when its not there.
When running the resize script as a separate thing on an open image it works fine. However if I run the script on a batch of images the same lame dialog box with the units appears, even when using your script without the ruler preferences. Any suggestions?
Kind regards,
Daniel Laflor
Copiar vínculo al Portapapeles
Copiado
Does it appear with every image or just some? Can you post a screenshot of the dialog?
Encuentra más inspiración, eventos y recursos en la nueva comunidad de Adobe
Explorar ahora