lgarron / folderify

:file_folder: Generate pixel-perfect macOS folder icons in the native style.
MIT License
1.54k stars 39 forks source link

Support for importing icons from applications #90

Closed samj closed 1 month ago

samj commented 1 month ago

I'd like to be able to import icons from the application that "owns" the folder, like Obsidian:

folderify /Applications/Obsidian.app ~/Obsidian

Failing that, importing the application's icon.icns file (which I guess you can get from its plist):

folderify '/Applications/Obsidian.app/Contents/Resources/icon.icns' ~/Obsidian

This is what I get when I try this currently: 

% RUST_BACKTRACE=full folderify '/Applications/Obsidian.app/Contents/Resources/icon.icns' ~/Obsidian
[/Applications/Obsidian.app/Contents/Resources/icon.icns] => assign to [/Users/samj/Obsidian]
[/Applications/Obsidian.app/Contents/Resources/icon.icns] Using folder style: BigSur
[/Applications/Obsidian.app/Contents/Resources/icon.icns] Using color scheme: light
             |  0/1  | (Input)    | Preparing icon mask                                                              identify: no decode delegate for this image format `ICNS' @ error/constitute.c/ReadImage/746.
thread 'main' panicked at src/main.rs:58:10:
called `Result::unwrap()` on an `Err` value: CommandFailed(CommandFailedError { command_name: "identify", stderr: [] })
stack backtrace:
   0:        0x1010bf9a0 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h14dcb4794e811c9f
   1:        0x1010cf29c - core::fmt::write::h49a9cf68bfb4a321
   2:        0x1010c2fe0 - std::io::Write::write_fmt::h00e4f1b82d71ad85
   3:        0x1010ac334 - std::panicking::default_hook::{{closure}}::hda52b8046522f561
   4:        0x1010abf70 - std::panicking::default_hook::h9566cb73367aef3e
   5:        0x1010accec - std::panicking::rust_panic_with_hook::hfa41181adbcf532d
   6:        0x1010c0404 - std::panicking::begin_panic_handler::{{closure}}::ha417e66bf9de7acf
   7:        0x1010bfbc8 - std::sys::backtrace::__rust_end_short_backtrace::hc7b890f013fa9efb
   8:        0x1010ac428 - _rust_begin_unwind
   9:        0x1010dcbc4 - core::panicking::panic_fmt::h29609029db4d41f4
  10:        0x1010dcb94 - core::result::unwrap_failed::h1a030347a5d7de67
  11:        0x10101ab38 - folderify::main::h9034cb627f056d9b
  12:        0x1010182e8 - std::sys::backtrace::__rust_begin_short_backtrace::hf696a5e51a05c756
  13:        0x10101b0cc - std::rt::lang_start::{{closure}}::h8ba350b6e8abe6a9
  14:        0x1010a4090 - std::rt::lang_start_internal::h31b5cf8a92666908
  15:        0x10101b0b0 - _main
lgarron commented 1 month ago

I don't think that will do what you want. You can certainly run:

iconutil --convert iconset --output /tmp/app.iconset /Applications/Obsidian.app/Contents/Resources/icon.icns
folderify --reveal /tmp/app.iconset/icon_512x512@2x.png

But most app icons are placed in a border, and would all produce folder icons looking like this:

icon_512x512@2x

folderify is more on the Unix philosophy side of things: it takes a mask and does the tricky macOS-specific parts of creating and setting a folder icon. There is no objective best way to take an arbitrary app icon and extract a mask from it, although you might have some luck using posterization with ImageMagick or an AI tool. But folderify isn't really needed for that part.

lgarron commented 1 month ago

Glad you found something that worked for you! Closing this issue for now.