Hi,
I can create these scripts separetely as you discribe or if you want you can share more about your process so maybe we can find some better solution or maybe this is maximal optimization which you can get I do not known that before you send me more information. But you not need as I said I can create scripts as it is on the images....
Generally I usually use Javascript for this, it run in back so it will be good for speed. I will send you detail explanation how to use that javascript file and how to made some changes in the code if you want to do that. I assume that you already have experience with this kind of work. And if you are not do not worry you only need to upload javascript in Photoshop and I run and for that u need a few seconds and couple of mouse clicks, after that script will run and u can do something more creative..
I have an experience of over seven years of work in Photoshop, Illustrator, InDesign, Acrobate, Adobe Lightroom, JavaScript associated with Adobe app, Python, Perl ... I am a very dedicated and diligent, so you can expect top quality.
Best regards,
Bojan