Resize Images with Predefined Max Size Macro

I did have this macro in the Macro Library but turns out it doesn't work properly.

It reduces the file too much. With further testing I can see it's reducing the file size a large percentage, when all I am doing is changing the pixel height and width by 1% (by using variable*.99 in the attached macro, I've also tried *99.9% with the following before and results:

DSC_4143 2397032
DSC_4143 1407715
DSC_4145 2494015
DSC_4145 921211
DSC_4146 2251735
DSC_4146 1188105
DSC_4147 2517155
DSC_4147 1440677
DSC_4148 1951988
DSC_4148 1522480

You can see the huge difference in filesize even though the adjustment is minimal. It works better as the file sizes get smaller (if I set max file file to 500k for eg). I'm wondering is it a DPI issue, does the clipboard do something to the images?

If anyone was able to have a look at it, but do beware, it is potentially destructive.

Thanks,
Damian

Resize Images with Predefined Max Size Macro (v9.0.6)

Resize Images with Predefined Max Size.kmmacros (13 KB)

By adding append to file actions, I've discovered more about this issue, it seems the first size reduction, even though it is only by 1%, reduces the size of the file by a significant amount. Perhaps this is metadata in the image file (1mb though?), or else some other .jpg data thing that I don't understand. That seems most likely. The original file comes from lightroom, the second is a dump from the clipboard. The DPI is slightly reduced, (297x296 vs 300x300) but I have a suspicion it's the colorsync profile that causes the big difference in filesize.

EDIT: Having gone down a colorsync rabbit hole, it appears it's sometimes important to use the sRGB that the original (large) file had, rather than the generic RGB that comes from the clipboard. Any visual experts out there? This macro was supposed to be for reducing file sizes on a photography website, but I may need to rethink that now.

Regardless, the log file gives very interesting results for two files being reduced by 1% to under 800000 bytes. Notice the huge initial drop:

Filename    Size        Width Height
DSC_4188 1883393 2048 1463 
DSC_4188 1167977 2028 1448 
DSC_4188 1101294 2008 1434 
DSC_4188 1051053 1988 1420 
DSC_4188 1002835 1968 1406 
DSC_4188 966648 1948 1392 
DSC_4188 933796 1929 1378 
DSC_4188 901063 1910 1364 
DSC_4188 871789 1891 1350 
DSC_4188 835715 1872 1337 
DSC_4188 808809 1853 1324 
DSC_4188 783465 1834 1311 

DSC_4182 2483588 2047 1356 
DSC_4182 1007750 2027 1342 
DSC_4182 962645 2007 1329 
DSC_4182 923824 1987 1316 
DSC_4182 886176 1967 1303 
DSC_4182 856677 1947 1290 
DSC_4182 825741 1928 1277 
DSC_4182 798317 1909 1264

I've been reading along but had no idea what you were trying to accomplish.

I'd suggest you try a little experiment. Run your large image through ImageOptim and see if the output file size doesn't satisfy your requirements.

That will produce a smaller file (with some options) without resizing. If you're concerned about how your photos will look don't resize them down without resampling them. And, yes, you do want a color profile.

If the resized file isn't small enough I'd export the file from Lightroom at a reduced size to start with (note the sharpening options in the Export dialog). If for some reason that isn't possible, I think you should look into resizing the image and sharpening with ImageMagick.

(I know all about screwing up this sort of stuff in every way possible, which I document along with industry news at Photo Corners.)

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?! :slight_smile:

Original


Copy

There's a checkbox in Lightroom's Export dialog that lets you set a limit on file size:

ss-527

I think that's all you need.

1 Like