You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.0 KiB

  1. #!/usr/bin/env python
  2. # This script regenerates the .icns files for MacOS application packaging.
  3. # You need to be running on MacOS to use it (for iconutil)
  4. # You also need imagemagick + rsvg installed, with something like:
  5. # brew install imagemagick --with-librsvg
  6. import os
  7. from shutil import copy, rmtree
  8. from subprocess import call
  9. ICON_SOURCES = "../../bitmaps_png/sources/"
  10. ICONS = [
  11. ("bitmap2component", ("bitmap2component",), "../../bitmap2component"),
  12. ("cvpcb", ("cvpcb", "cvpcb_doc"), "../../cvpcb"),
  13. ("eeschema", ("eeschema", "eeschema_doc"), "../../eeschema"),
  14. ("gerbview", ("gerbview", "gerbview_doc"), "../../gerbview"),
  15. ("kicad", ("kicad", "kicad_doc"), "../../kicad"),
  16. ("pagelayout_editor", ("pl_editor", "pl_editor_doc"), "../../pagelayout_editor"),
  17. ("pcbcalculator", ("pcb_calculator",), "../../pcb_calculator"),
  18. ("pcbnew", ("pcbnew", "pcbnew_doc"), "../../pcbnew")
  19. ]
  20. SIZES = [
  21. ("!16x16", ("16x16",)),
  22. ("!32x32", ("16x16@2x", "32x32")),
  23. ("!64x64", ("32x32@2x",)),
  24. ("!128x128", ("128x128",)),
  25. ("!256x256", ("128x128@2x", "256x256")),
  26. ("!512x512", ("256x256@2x", "512x512")),
  27. ("!1024x1024", ("512x512@2x",))
  28. ]
  29. if __name__ == '__main__':
  30. for src, dest, finaldir in ICONS:
  31. src = ICON_SOURCES + "icon_" + src + ".svg"
  32. iconset = dest[0] + ".iconset"
  33. os.mkdir(iconset)
  34. for size, outputs in SIZES:
  35. dest_path = os.path.join(iconset, "icon_" + outputs[0] + ".png")
  36. print size, src, dest_path
  37. call(["convert", "-background", "none", "-density", "5000",
  38. "-resize", size, src, dest_path])
  39. for duplicate in outputs[1:]:
  40. dupe_path = os.path.join(iconset, "icon_" + duplicate + ".png")
  41. copy(dest_path, dupe_path)
  42. call(["iconutil", "-c", "icns", iconset])
  43. rmtree(iconset)
  44. for dupe in dest[1:]:
  45. copy(dest[0] + ".icns", os.path.join(finaldir, dupe + ".icns"))
  46. copy(dest[0] + ".icns", finaldir)
  47. os.remove(dest[0] + ".icns")