Advertisement

Windows 7 - icons shown with wrong size (folder thumbnail alternative).

Started by December 07, 2014 10:56 PM
4 comments, last by tanzanite7 9 years, 9 months ago
Since Windows 7 folder thumbnail feature was degraded to being completely unusable from XP days - i though of an alternative:

iconify.reg
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\someDefaultJpgHandler\shell\iconify]
@="Iconify"

[HKEY_CLASSES_ROOT\someDefaultJpgHandler\shell\iconify\command]
@="cmd.exe /d /c \"c:\\somewhere\\iconify.bat \"%1\"\""

...etc
Where "someDefaultJpgHandler" is from "HKEY_CLASSES_ROOT\.jpg" default value.

iconify.bat
@echo off

:: imagemagick
convert "%~n1%~x1" -resize x128 -gravity center -crop 128x128+0+0 -alpha remove -colors 256 "folder.ico"

attrib -s -h desktop.ini
del desctop.ini

(
  echo [ViewState]
  echo Mode=
  echo Vid=
  echo FolderType=Generic
  echo Logo=
  echo [.ShellClassInfo]
  echo IconResource=.\folder.ico,0
) > desktop.ini

attrib -a +s +h desktop.ini
Works nicely - i can pick "Iconify" on any picture file and it will be shown as the folder icon.

... except - Windows ignores the icon size and persist on showing as 48x48. Even with "View -> extra large icons" option (48x48 seems to be the icon size my desktop uses).
Thought that perhaps it would help if i give multiple resolutions - nope.
convert "%~n1%~x1" -bordercolor white -border 0 ^
  ^( -clone 0 -resize x16 -gravity center -crop 16x16+0+0 ^) ^
  ^( -clone 0 -resize x32 -gravity center -crop 32x32+0+0 ^) ^
  ^( -clone 0 -resize x48 -gravity center -crop 48x48+0+0 ^) ^
  ^( -clone 0 -resize x64 -gravity center -crop 64x64+0+0 ^) ^
  ^( -clone 0 -resize x128 -gravity center -crop 128x128+0+0 ^) ^
  -delete 0 -alpha remove -colors 256 "folder.ico"
PS. afaik 128x128 are the dimensions for "Large icons" option - which i would prefer.
PS2. there is no problem when i use some random windows stock icon.



I'm stuck and Google gives me nothing. Help! WTF is going on?

I'm not sure what you're trying to achieve. I'm using Windows 7, and thumbnails work fine...

[rollup=Screenshot from my machine]Screenshot1.png[/rollup]

[rollup=Even bigger thumbnails]Screenshot2.png[/rollup]

[Edit:] Oops, I misunderstood your problem. rolleyes.gif

I thought this was a Windows 7 question but it seems to be more of an ImageMagick question. Have you seen this, about using the -define: command? ( -define icon:auto-resize )

I've used ImageMagick before, but not with .ico formats.

Advertisement

I'm not sure what you're trying to achieve. I'm using Windows 7, and thumbnails work fine...

I am talking about FOLDER thumbnails. I use classic shell and they say that non-shit version does not exist in windows anymore and hence they can not do anything to help (Last post i remember encountering about it was something in the 2014 - doubt anything has changed. Would love to be proven wrong).

Random example from web: http://i51.tinypic.com/se8zmd.jpg

I thought this was a Windows 7 question but it seems to be more of an ImageMagick question. Have you seen this, about using the -define: command? ( -define icon:auto-resize )

I've used ImageMagick before, but not with .ico formats.

Yes, i suspect some quirk with imagemagick or windows that i am unable to track down. Example of what my script produces vs random windows stock icon: http://oi62.tinypic.com/2yzc56o.jpg

I think i found a workaround for the quirk (now it looks as it should: http://oi62.tinypic.com/1fz0h.jpg ). Somewhy windows demands that 256x256 version exists (it does not care about the other [more appropriate] ones - so, "icon:auto-resize" just makes the file bigger [just in case tested 256/128 options with it -> no benefit, just a bigger file and fails/works the same as only one size]).

So, a massive waste of space is required (i actually only need 128x128 or 96x96 [not sure which, tried both but only 256x256 works]). Am i still missing something or is there something i could do?

----------------
For completeness sake, i post the updated script that is invoked from context menu (also added icon cache flush for instant effect):
@echo off

convert "%~n1%~x1" -bordercolor none -resize x256 -gravity center -crop 256x256+0+0 -alpha remove -colors 256 "folder.ico"

attrib -s -h desktop.ini
del desktop.ini
(
  echo [ViewState]
  echo Mode=
  echo Vid=
  echo FolderType=Generic
  echo [.ShellClassInfo]
  echo IconResource=.\folder.ico,0
) > desktop.ini
attrib -a +s +h desktop.ini

ie4uinit.exe -ClearIconCache
----------------
edit:
"So the result: Windows XP uses 16, 32, 48-size icons, while Windows 7 (and presumably also Vista) also uses 256-size icons. All other intermediate icon sizes are ignored"
via http://stackoverflow.com/questions/3236115/which-icon-sizes-should-my-windows-applications-icon-include
Seems that windows is just trying to be funny and there is nothing one can do. Just have to accept the silly filesizes.

----------------
edit2:
Wiki said ico can contain compressed png, so after digging in imagemagick documentation - i finally found "When writing an ICO file, you may request that the images be encoded in PNG format, by specifying Zip compression".
Indeed, windows accepts such a file ("-compress Zip") halving the filesize. Having seen the contents of the unpacked file - my gut feeling is that it could be packed more ... but no idea how to tell imagemagick that. Still, i am finally at the point where i am at least happy with the results.
Had a epiphany while doing other stuff - and after digging around in documentation:

convert "%~n1%~x1" -alpha remove -colors 256 -bordercolor none -resize x128 -gravity center -crop 128x128+0+0 ^
  ^( -clone 0 -filter Box -resize 256x256 ^) ^
  -delete 0 -define png:format=png8 -compress Zip folder.ico
Windows is happy and i am happy smile.png (Not an imagemagick expert, so probably something unneeded there - but whatever. IT WORKS!)

... final filesize for 256x256-photo icon -> 12KB. No actual loss in quality compared to 256-color, but otherwise uncompressed, 256x256 ico.
I can just imagine some poor soul years from now coming across this thread and being thankful you actually posted a fully working example =-)

wisdom_of_the_ancients.png
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

Hehe. Yeah, have been the poor sod myself often enough to take the extra time/effort to post what i figured out :)

This topic is closed to new replies.

Advertisement