USE CASE
I need to quickly get an image preview/thumbnail (~512px) of a batch of large multi-GB images on import into FileMaker to accompany metadata that is accessed with the aid of ExifTool.
SOURCE IMAGES
The original images could be as large as 10GB+, 8-bit to 32-bit, RGB or CMYK, layered or flattened, with or without Alpha/Spot Changes, with or without background transparency, and are saved from Photoshop as either TIFs, PSDs, PSBs, PNGs, JPEGS, or HEICs with Thumbnails and Maximize Compatibility enabled.
EXPERIMENTATION:
ExifTool can generate 160px thumbnails from the embedded -PhotoshopThumbnails tag, but that’s smaller than I’d like:
Code: Select all
exiftool -b -PhotoshopThumbnail in_path > out_path
Code: Select all
exiftool -a -b -W %d%f_%t%-c.%s -preview:all DIR
https://community.adobe.com/t5/photosho ... 28#M772048
Code: Select all
var file = new File("F:\\((\\test.psb");
var jpg = new File("F:\\((\\test.jpg");
main(file, jpg);
function main(file, jpg)
{
try {
file.open("r");
file.encoding = "BINARY";
var offset = 0;
var hrd_len = 26;
var buff = file.read(hrd_len);
offset += hrd_len;
var color_mode_len = get_integer(file.read(4));
offset += 4 + color_mode_len;
file.seek(offset, 0);
var image_resource_len = get_integer(file.read(4));
offset += 4 + image_resource_len;
var buff = file.read(image_resource_len);
file.close();
var x = buff.indexOf("8BIM\x04\x0C\x00\x00");
if (x < 0) { alert("Thumbnail not found"); return; }
var len = get_integer(buff.substr(x+8, 4));
buff = buff.substr(x+12);
var format = get_integer(buff.substr(0, 4));
var w = get_integer(buff.substr(4, 4));
var h = get_integer(buff.substr(8, 4));
buff = buff.substr(28, len-28);
jpg.open("w");
jpg.encoding = "BINARY";
jpg.write(buff);
jpg.close();
alert("Thumbnail " + w + "x" + h);
}
catch (e) { alert(e); throw(e); }
}
function get_integer(s)
{
try {
var len = s.length;
var mult = 1;
var ret = 0;
for (var i = len-1; i >=0; i--)
{
ret += s.charCodeAt(i) * mult;
mult *= 256;
}
return ret;
}
catch (e) { alert(e); throw(e); }
}
Code: Select all
qlmanage -t source_path_to_file -s 512 -o out_path
ImageMagick is too slow when working with multi-GIG PSBs and it’s not feasible to generate from Photoshop.
Adobe Bridge seems to be able to get large previews quickly of 10GB+ files when set to process files this big. How does it do that/where does that data come from? Is there a way to replicate the creation of that outside of Bridge? JavaScript?
MacOS Finder Preview also is unable to generate previews of PSBs that get into the ~4.5GB range.
Any way to do this with JavaScript or Python in combination with FileMaker to quickly access/produce previews/thumbnails on 10GB+ PSBs in the 512px range on import?
Seems like reading composite data would be the fastest way to access? From there would need to ensure 8-bit, RGB, sRGB profile, remove all alpha channels except BKG transparency... essentially a thumbnail, but larger than 160px.