Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge in changes from upstream? #2

Open
SlySven opened this issue Oct 5, 2020 · 21 comments
Open

Merge in changes from upstream? #2

SlySven opened this issue Oct 5, 2020 · 21 comments

Comments

@SlySven
Copy link

SlySven commented Oct 5, 2020

I note that the upstream project, now located at: https://icns.sourceforge.io/ rather than http://icns.sourceforge.net/ has not visibly gained a release since 0.8.1 but there has been developments since your commit-e261b0a2 which corresponds to its commit-91e2f813 such that it has less spelling errors, odd-line endings (check icnsutils/png2icns.c!), supports OpenJPEG version 2 as well as 1, and has removed some obsolete SVN junk. Basically the code is cleaner however it does not have your support for 128px (ic07) icon types or for avoiding the need to re-encode the .png image data .

Do you think there is any chance of bringing in the changes upstream - and/or passing back to them your enhancements?

@pabs3
Copy link
Contributor

pabs3 commented Oct 6, 2020

It looks like @kornelski made this fork before we switched the SourceForge project from Subversion to Git, because the Git history is not linked between the two projects.

I'm happy to do the work needed to merge the changes from the @kornelski fork into the SourceForge Git repository if @kornelski is happy with that. I am likely to need to adjust the commits slightly, since I noticed they include unrelated whitespace changes.

I don't intend to move libicns from SourceForge to GitHub as switching hosting locations is too disruptive to users and redistributors and the two platforms have similar functionality.

In case you @SlySven or @kornelski or others are interested in joining the SourceForge project, I'm happy to add you there.

If either of you have a sample of the ic07 icon type produced by a macOS machine, that would be helpful for validating the related code changes.

@kornelski
Copy link
Owner

No problem. Feel free to take the code.

@SlySven
Copy link
Author

SlySven commented Oct 6, 2020

What can be done about version numbers? The code in this repository has advanced them to 0.9.0 but the upstream has not had an increment for eight years or so and is still on 0.8.1. I suppose that if upstream went to a 0.9.1 after it gained the ic07 and the .png reuse feature then it would reflect to third parties which would be the recommended one. However I am guessing that you @kornelski are not going to want to archive (lock and make read-only) this repository yet there would be other differences between the two that mean that they are not mirrors of each other. 🤔

Unfortunately I cannot help with that particular icon type as I don't have a Mac - which is what lead me into this area in the first place. 😆

But anyhow, thanks to you both for talking to each other.

@Luflosi
Copy link

Luflosi commented Oct 6, 2020

Here is the firefox icon. I'm quite sure it contains the ic07 icon type. Let me know if this is what you were looking for.
firefox.icns.zip

@SlySven
Copy link
Author

SlySven commented Oct 7, 2020

That is an interesting specimen, which indeed does seem to contain the ic07 type.

stephen@Ripley:~/src/libicns$ icns2png -l ./firefox.icns
----------------------------------------------------
Reading icns family from ./firefox.icns...
 Extracting icons from /firefox.icns...
 Icon family size is 1021785 bytes (including 8 byte header)
 Listing icon elements...
  's8mk' 16x16 8-bit mask (256 bytes)
  'is32' 16x16 32-bit icon (1024 bytes compressed to 642)
  'l8mk' 32x32 8-bit mask (1024 bytes)
  'il32' 32x32 32-bit icon (4096 bytes compressed to 2031)
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic07'
  'ic07' 0x0 0-bit (18391 bytes)
  'ic08' 256x256 32-bit icon (262144 bytes compressed to 50218)
  'ic09' 512x512 32-bit icon (1048576 bytes compressed to 177374)
  'ic10' 1024x1024 32-bit icon (4194304 bytes compressed to 550467)
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic11'
  'ic11' 0x0 0-bit (2244 bytes)
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic12'
  'ic12' 0x0 0-bit (6115 bytes)
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic13'
  'ic13' 0x0 0-bit (56903 bytes)
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic14'
  'ic14' 0x0 0-bit (156016 bytes)
12 elements total found in /firefox.icns.
stephen@Ripley:~/src/libicns$

For reference on the other types I am referring to: https://en.wikipedia.org/wiki/Apple_Icon_Image_format#Icon_types .

@pabs3
Copy link
Contributor

pabs3 commented Oct 7, 2020 via email

@Luflosi
Copy link

Luflosi commented Oct 7, 2020

Here is the Blender icon, which contains the ic04 and ic05 icon types you were looking for. I looked through a bunch of other app icons on my system but couldn't find any of the others. Is there a way to check programmatically if an icon contains a certain type? So far I just used macOS Preview to do the job.
blender icon.icns.zip

@pabs3
Copy link
Contributor

pabs3 commented Oct 7, 2020 via email

@Luflosi
Copy link

Luflosi commented Oct 7, 2020

025_Receiver_Combo_Mac.icns.zip contains the icsB and icsb icon types.
document.icns.zip contains the icp4 and icp5 icon types.
programmer.icns.zip contains the icp6 icon type.

@pabs3
Copy link
Contributor

pabs3 commented Oct 11, 2020

Added support for icp6 upstream since that was pretty easy.

The icp4 and icp5 types don't seem to match what Wikipedia says. The icsB and icsb have no description on Wikipedia. The ic04 and ic05 types will need a new decoder to be written as there are no other types in this ARGB format.

@pabs3
Copy link
Contributor

pabs3 commented Oct 11, 2020

@Luflosi: any chance of some more samples of each type? Would be interesting to see if any of the other samples of icp4 and icp5 use PNG like Wikipedia suggests. For the others it would be useful to have a more than one sample for extra validation.

@Luflosi
Copy link

Luflosi commented Oct 13, 2020

Unfortunately, I couldn't find any more icons with the icp6 icon type. 025_Apps_Combo_Mac.icns is from the same application bundle as 025_Receiver_Combo_Mac.icns from my last comment, so it probably has the same properties.
SKEAR_Mac.icns.zip contains the icsB type.
DVTGenericiOSDevice.icns.zip contains the icsB and icsb types.
025_Apps_Combo_Mac.icns.zip contains the icsB and icsb types.
APPL.icns.zip contains the icp4 and icp5 types.

Are there any other types you're interested in?

@pabs3
Copy link
Contributor

pabs3 commented Oct 13, 2020 via email

@SlySven
Copy link
Author

SlySven commented Oct 14, 2020

😊 It is a bit embarrassing but I was going through my project's artwork repository and I found an .icns that someone else had done - not sure if it was on a genuine 🍏 machine or they did it on-line but it has a load of formats that I cannot currently process with https://sourceforge.net/p/icns/code/ci/382937bb38ff1ab3513a7ef232b2a562433ec1be/ - it looks like all the "Retina ones":

stephen@Ripley:~/src/libicns$ icns2png -l ~/src/mudlet-dev/Mudlet/mudlet/src/icons/mudlet.icns
----------------------------------------------------
Reading icns family from /home/stephen/src/mudlet-dev/Mudlet/mudlet/src/icons/mudlet.icns...
 Extracting icons from /mudlet.icns...
 Icon family size is 914427 bytes (including 8 byte header)
 Listing icon elements...
  'TOC ' table of contents
  'ic08' 256x256 32-bit icon (262144 bytes compressed to 54444)
  'ic10' 1024x1024 32-bit icon (4194304 bytes compressed to 461443)
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic13'
  'ic13' 0x0 0-bit (54444 bytes)
  'ic09' 512x512 32-bit icon (1048576 bytes compressed to 156444)
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic12'
  'ic12' 0x0 0-bit (6232 bytes)
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic07'
  'ic07' 0x0 0-bit (18279 bytes)
  'il32' 32x32 32-bit icon (4096 bytes compressed to 2280)
  'l8mk' 32x32 8-bit mask (1024 bytes)
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic11'
  'ic11' 0x0 0-bit (2231 bytes)
  'is32' 16x16 32-bit icon (1024 bytes compressed to 698)
  's8mk' 16x16 8-bit mask (256 bytes)
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic14'
  'ic14' 0x0 0-bit (156444 bytes)
13 elements total found in /mudlet.icns.
stephen@Ripley:~/src/libicns$ 

From that Wikipedia page that works out to be:

  • ic07 128x128 icon in JPEG 2000 or PNG format
  • ic11 16x16@2x icon "retina" icon in JPEG 2000 or PNG format
  • ic12 32x32@2x icon "retina" icon in JPEG 2000 or PNG format
  • ic13 128x128@2x icon "retina" icon in JPEG 2000 or PNG format
  • ic14 256x256@2x icon "retina" icon in JPEG 2000 or PNG format

Here is the file - zipped up so I can attach it here:
mudlet.zip

@pabs3
Copy link
Contributor

pabs3 commented Oct 14, 2020 via email

@SlySven
Copy link
Author

SlySven commented Oct 14, 2020

🤦‍♂️ I still had some earlier system libraries around from my Distribution - having disposed of them the extraction went fine and I was able to recover all the icon files - however I could not round trip them and make a new .icns with all the files, it looks like the png2icns tool might need some more work:

stephen@Ripley:~/src/mudlet-dev/Mudlet/mudlet/src/icons/test$ icns2png -x ../mudlet.icns 
----------------------------------------------------
Reading icns family from ../mudlet.icns...
 Extracting icons from /mudlet.icns...
  Saved 'ic08' element to mudlet_256x256x32.png.
  Saved 'ic10' element to mudlet_1024x1024x32.png.
  Saved 'ic13' element to mudlet_256x256x32.png.
  Saved 'ic09' element to mudlet_512x512x32.png.
  Saved 'ic12' element to mudlet_64x64x32.png.
  Saved 'ic07' element to mudlet_128x128x32.png.
  Saved 'il32' element to mudlet_32x32x32.png.
  Saved 'ic11' element to mudlet_32x32x32.png.
  Saved 'is32' element to mudlet_16x16x32.png.
  Saved 'ic14' element to mudlet_512x512x32.png.
Extracted 10 images from /mudlet.icns.
stephen@Ripley:~/src/mudlet-dev/Mudlet/mudlet/src/icons/test$ ls -lart
total 592
drwxrwxr-x 3 stephen stephen  12288 Oct 14 02:05 ..
-rw-r--r-- 1 stephen stephen 351769 Oct 14 02:05 mudlet_1024x1024x32.png
-rw-r--r-- 1 stephen stephen  50662 Oct 14 02:05 mudlet_256x256x32.png
-rw-r--r-- 1 stephen stephen   6408 Oct 14 02:05 mudlet_64x64x32.png
-rw-r--r-- 1 stephen stephen  18127 Oct 14 02:05 mudlet_128x128x32.png
-rw-r--r-- 1 stephen stephen   2183 Oct 14 02:05 mudlet_32x32x32.png
-rw-r--r-- 1 stephen stephen    791 Oct 14 02:05 mudlet_16x16x32.png
drwxr-xr-x 2 stephen stephen   4096 Oct 14 02:05 .
-rw-r--r-- 1 stephen stephen 134249 Oct 14 02:05 mudlet_512x512x32.png
stephen@Ripley:~/src/mudlet-dev/Mudlet/mudlet/src/icons/test$ png2icns mudlet.icns ./*.png
Using icns type 'ic10' (ARGB) for './mudlet_1024x1024x32.png'
Using icns type 'ic07' (ARGB) for './mudlet_128x128x32.png'
Using icns type 'is32', mask 's8mk' for './mudlet_16x16x32.png'
Using icns type 'ic08' (ARGB) for './mudlet_256x256x32.png'
Using icns type 'il32', mask 'l8mk' for './mudlet_32x32x32.png'
Using icns type 'ic09' (ARGB) for './mudlet_512x512x32.png'
Using icns type 'ic12', mask '' for './mudlet_64x64x32.png'
libicns: icns_get_image_info_for_type: Unable to parse NULL type!
libicns: icns_init_image: icon width is 0!
libicns: icns_update_element_with_image_or_mask: Invalid icon type!
Saved icns file to mudlet.icns

It looks like it is having difficulty with the ic12 type as it is trying tot report a mask '' instead of saying it is an (ARGB) encoding - if we then try to examine the new file:

stephen@Ripley:~/src/mudlet-dev/Mudlet/mudlet/src/icons/test$ icns2png -l ./mudlet.icns 
----------------------------------------------------
Reading icns family from ./mudlet.icns...
 Extracting icons from /mudlet.icns...
 Icon family size is 565553 bytes (including 8 byte header)
 Listing icon elements...
  'is32' 16x16 32-bit icon (1024 bytes compressed to 698)
  's8mk' 16x16 8-bit mask (256 bytes)
  'il32' 32x32 32-bit icon (4096 bytes compressed to 2280)
  'l8mk' 32x32 8-bit mask (1024 bytes)
  'ic08' 256x256 32-bit icon (262144 bytes compressed to 50662)
  'ic09' 512x512 32-bit icon (1048576 bytes compressed to 134249)
  'ic12' 64x64 32-bit icon (16384 bytes compressed to 6408)
  'ic07' 128x128 32-bit icon (65536 bytes compressed to 18127)
  'ic10' 1024x1024 32-bit icon (4194304 bytes compressed to 351769)
9 elements total found in /mudlet.icns.

So it HAS inserted the ic12 one, I note that the missing ones {ic11, ic13 and ic14} are all ones that could be @2x high dpi (i.e. 144pdi) as opposed to 72dpi standard ones; and thinking more deeply I remember now that although I was careful to create both files like [email protected] (144dpi) AND icon_512x512.png (72dpi) the png2icns tool would reject the second one as the particular slot was already filled. Examining the output from icn2png -x I now see that it was treating the doubled dpi images wrongly:

  Saved 'ic08' element to mudlet_256x256x32.png.
  ...
  Saved 'ic13' element to mudlet_256x256x32.png.

BUT IT SHOULD HAVE SAVED THE LATTER AS [email protected]...

@pabs3
Copy link
Contributor

pabs3 commented Oct 14, 2020 via email

@Luflosi
Copy link

Luflosi commented Oct 14, 2020

xyscan.icns.zip
I'll look for a few icons with type info and name soon-ish.

@Luflosi
Copy link

Luflosi commented Oct 28, 2020

Here are some samples with type info and name: info.zip name.zip
Did you get a chance to look at the other file I provided in the comment above yet?
Anything else I can help with?
Will you please make a new release within the next couple months? The last release is from eight years ago.

@pabs3
Copy link
Contributor

pabs3 commented Oct 29, 2020 via email

@atzlinux
Copy link

I also meet the icon type 'ic04' 'ic05' 'info' Unable to parse , the icns is:

https://github.com/PetoiCamp/OpenCat/blob/main/pyUI/resources/logo.icns

icns2png -x pyUI/resources/logo.icns -o debian/

Reading icns family from pyUI/resources/logo.icns...
Extracting icons from /logo.icns...
Saved 'ic12' element to debian/logo_64x64x32.png.
Saved 'ic07' element to debian/logo_128x128x32.png.
Saved 'ic13' element to debian/logo_256x256x32.png.
Saved 'ic08' element to debian/logo_256x256x32.png.
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic04'
Saved 'ic14' element to debian/logo_512x512x32.png.
Saved 'ic09' element to debian/logo_512x512x32.png.
libicns: icns_get_image_info_for_type: Unable to parse icon type 'ic05'
Saved 'ic11' element to debian/logo_32x32x32.png.
libicns: icns_get_image_info_for_type: Unable to parse icon type 'info'
Extracted 7 images from /logo.icns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants