jimmybreeze
New Member
- Messages
- 4
- Likes
- 0
Hi there,
I'm pretty new to all this stuff but I've been doing a LOT of processing of images of late. I'm sure what I want to do can be done with scripts or automation though.
My scenario is this:
I have a folder with a lot of subfolders, many with a bunch of TIFFs inside. Some of these have transparency in them while some don't. These files vary massively in size.
I need all the files to be turned into JPGs, or if they contain transparency, PNGs. I require the files to be 200kb or less and don't really mind how large they are as long as they aren't scaled up.
I spotted this bit of script and was wondering if that might be at least a little useful as a start but I'd much rather learn a little more about how scripting might be able to assist me in this situation.
var SizeOfFile = prompt("Please Enter Size In Megabytes",17)
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;
}
I don't know if you guys could help me but anything you could would be massively appreciated and would totally help me out of this nightmare. I've got around 500GB of data to get through.
Thanks in advance,
Dan
I'm pretty new to all this stuff but I've been doing a LOT of processing of images of late. I'm sure what I want to do can be done with scripts or automation though.
My scenario is this:
I have a folder with a lot of subfolders, many with a bunch of TIFFs inside. Some of these have transparency in them while some don't. These files vary massively in size.
I need all the files to be turned into JPGs, or if they contain transparency, PNGs. I require the files to be 200kb or less and don't really mind how large they are as long as they aren't scaled up.
I spotted this bit of script and was wondering if that might be at least a little useful as a start but I'd much rather learn a little more about how scripting might be able to assist me in this situation.
var SizeOfFile = prompt("Please Enter Size In Megabytes",17)
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;
}
I don't know if you guys could help me but anything you could would be massively appreciated and would totally help me out of this nightmare. I've got around 500GB of data to get through.
Thanks in advance,
Dan