Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Icons are overweight. How do I reduce them?

Icons are overweight. How do I reduce them?
Thread Tools
Uncle Skeleton
Addicted to MacNN
Join Date: Nov 2002
Location: Rockville, MD
Status: Offline
Reply With Quote
Jan 22, 2024, 11:58 AM
 
I like to paste custom icons on files, in Finder. I recently updated to OS X Sonoma (14.2.1) from Big Sur, and now custom icons add about 1.5 to 2 MB to the file. That's insane.
I pulled out an older mac that still has High Sierra, and the custom icons there only add 50KB max. Actually, now that I think about it the enormous icons were probably in Big Sur too.

I want to be able to add 50KB custom icons using my current mac. How do I do it?

I tried to google this, and I found that I can use the cli app iconutil to create a .icns file (29KB, with a more-than-adequate 256x256 png image). But if I use Finder to copy this icon to a new file, the new file grows by 2MB, and if I copy the icon back out, into Preview, it has all these (superfluous) extra resolutions, which is probably why it's 2MB.

Thank you in advance
     
andi*pandi
Moderator
Join Date: Jun 2000
Location: inside 128, north of 90
Status: Offline
Reply With Quote
Jan 22, 2024, 01:14 PM
 
long ago I would have checked the iconfactory for their handy icon app. but it seems they have moved on to bigger and brighter things.
     
reader50
Administrator
Join Date: Jun 2000
Location: California
Status: Online
Reply With Quote
Jan 22, 2024, 04:27 PM
 
I used to apply custom picture icons. So they'd all render immediately in Finder when you open a pics folder. Today, those old pic files all show low-res icons. And most of the utilities I once used for adding or removing custom icons were lost after Mojave. They all seemed to be 32-bit.

I mostly let Finder generate icons on the fly now, and I could remove old custom icons one-at-a-time in the info dialog. Or I could do batches from Mojave. The problem hasn't annoyed me enough to do either. Yet.

If anyone knows of a 64-bit batch utility for generating / removing picture icons, I'd appreciate it. None of my old standbys are being maintained.
     
Uncle Skeleton  (op)
Addicted to MacNN
Join Date: Nov 2002
Location: Rockville, MD
Status: Offline
Reply With Quote
Jan 23, 2024, 10:43 AM
 
Thanks for the replies. Still pursuing...

Originally Posted by reader50 View Post
I could remove old custom icons one-at-a-time in the info dialog. Or I could do batches from Mojave.
I just tested in Sonoma, search for ".jpeg", select all, get info, delete icon.
In so doing, I also learned you can get a "merged" info window even with few items, with cmd-opt-i.
Then while writing this comment, I learned that the File menu options in Finder change as you hold down modifier keys

If anyone knows of a 64-bit batch utility for generating / removing picture icons, I'd appreciate it. None of my old standbys are being maintained.
GraphicConverter? I haven't tried it with icons, but I have done batch conversions that maintain folder hierarchies
     
Uncle Skeleton  (op)
Addicted to MacNN
Join Date: Nov 2002
Location: Rockville, MD
Status: Offline
Reply With Quote
Jan 23, 2024, 11:56 AM
 
So I made some progress. Various sites say you can set icons with NSWorkspace in cocoa, and I didn't muster the trust to download and run someone's arbitrary app, I did write my own, and tentatively it works! It runs in Sonoma, and it creates file icons that only add KB not MB to the file size.

Here is my code:
Code:
#import <Foundation/Foundation.h> #import <Cocoa/Cocoa.h> NSImage *resizedImage(NSImage *sourceImage) { // https://stackoverflow.com/questions/11949250/how-to-resize-nsimage/38442746#38442746 if (! sourceImage.isValid) return nil; NSSize oldSize = [sourceImage size]; NSSize newSize = NSMakeSize(oldSize.width, oldSize.width); if (oldSize.height > oldSize.width) newSize = NSMakeSize(oldSize.height, oldSize.height); NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:newSize.width pixelsHigh:newSize.height bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0]; rep.size = newSize; [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:rep]]; int x = 0; int y = 0; if (oldSize.width > oldSize.height) { y = (newSize.height - oldSize.height) / 2; } if (oldSize.height > oldSize.width) { x = (newSize.width - oldSize.width) / 2; } [sourceImage drawInRect:NSMakeRect(x, y, oldSize.width, oldSize.height) fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0]; [NSGraphicsContext restoreGraphicsState]; NSImage *newImage = [[NSImage alloc] initWithSize:newSize]; [newImage addRepresentation:rep]; return newImage; } int main(int argc, const char * argv[]) { @autoreleasepool { NSLog(@"usage: iconia <image file> <destination file>"); NSString *myImage = [NSString stringWithCString:argv[1] encoding:NSUTF8StringEncoding]; NSString *myFile = [NSString stringWithCString:argv[2] encoding:NSUTF8StringEncoding]; NSImage *im = [[NSImage alloc] initWithContentsOfFile:myImage]; NSImage *im2 = resizedImage(im); [[NSWorkspace sharedWorkspace] setIcon:im2 forFile:myFile options:NSExclude10_4ElementsIconCreationOption]; } return 0; }
( Last edited by Uncle Skeleton; Jan 23, 2024 at 01:24 PM. Reason: fixed the problem of it forcing square dimensions)
     
Brien
Professional Poster
Join Date: Jun 2002
Location: Southern California
Status: Offline
Reply With Quote
Jan 27, 2024, 01:37 AM
 
But why, I wonder, have the sizes embiggened?
     
reader50
Administrator
Join Date: Jun 2000
Location: California
Status: Online
Reply With Quote
Jan 27, 2024, 02:39 AM
 
Retina displays.

also, our eyesight may not be what it used to be
     
CharlesS
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Jan 28, 2024, 08:51 PM
 
It's because the modern icns format contains one 1024x1024 image, two 512x512 images, two 256x256 images, as well as all the 128x128 and smaller image sizes that were available way back in Mac OS X 4K78. The reason there are two of so many of these is because there's two sets of images; one for HiDPI mode and one for standard. So for example, one of the 512x512 images is actually a double-resolution version of the 256x256 for use on Retina displays, whereas the other one is a 512x512 version for standard displays, for anyone insane enough to have their icon size set that high. All those images take up space.

If it makes you feel any better, the maximum size of a Mac resource fork is 16 MiB, so they won't be able to grow the sizes bigger than that (unless, of course, they finally move the custom icons out of the resource fork and into an extended attribute like they honestly probably should have done years ago).

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
andi*pandi
Moderator
Join Date: Jun 2000
Location: inside 128, north of 90
Status: Offline
Reply With Quote
Jan 29, 2024, 01:11 PM
 
^this guy icons.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:49 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,