Wow, an actual expert. Thanks for taking the time to comment.
My apologies. I'm often not the best at communicating online, or perhaps in person either. As has often been stated 'Explain what the macro is for, and is trying to do', and I didn't.
A family member takes photographs of outdoor events and puts them online for the participants to purchase. It is more a hobby than anything else, and it is run on a wordpress site with a purchased plugin WP-Photoseller. The hosting though is low cost, and so the plugin can only handle files of around 2.5MB before it starts freezing during the watermarking process, causing endless problems. The simplest solution was to keep files under 2.5MB.
The photographer processes the files in lightroom and saves them before uploading to the server. The way he does this, the largest of the files are 2.5MB but if he has cropped the image a lot, the files can be as small as 1.2MB or so. It occurred to me that if he started with all the files a bit larger, say 3.5MB, then he could use my macro to bring them down to just under 2.5MB. The largest of his files would stay the same, but the smaller ones would end up being larger. I hope that's clear.
Running the images through ImageOptin typically takes 200k of an average file. It was the possibility to keep shaving percentages off the filesize until it came in at just under 2.5MB that was the attractive part of my macro.
ImageMagick is completely possible of course. Are you saying that the process of copying the file to the clipboard and then back to a file could cause problems? If so, I will look into using ImageMagick. The macro will be a little tricker, but I'll get there.
There are two photos below. The first is the original with a sRGB IEC61966-2.1 color profile and was 2.47MB, the second was run through a variation of the macro, but resizing at 100% (so not resizing), and CMD-I tells me it has a Generic RGB Profile, and is 1.58MB. The original file, when run through imageoptim is reduced by 8.3% to 2.27MB. It seems so strange. If there was nothing wrong with using the resulting file, then the process works perfectly, but there are probably image issues I just don't understand. What do you think? This is probably me 'screwing up stuff in every way possible' right?!
Original
Copy