Skip to content

Commit

Permalink
Some random support files
Browse files Browse the repository at this point in the history
In particular, these are for dealing with Icons.
  • Loading branch information
acaird committed May 24, 2021
1 parent de4cbde commit 5a4121a
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 0 deletions.
107 changes: 107 additions & 0 deletions support/makeiconset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
"""
This is from:
Convert PNG to ICNS on Mac OS
https://retifrav.github.io/blog/2018/10/09/macos-convert-png-to-icns/
and:
https://github.com/retifrav/python-scripts/blob/master/generate-iconset/generate-iconset.py
"""
import sys
import pathlib
import subprocess

if len(sys.argv) < 2:
print("No path to original / hi-res icon provided")
raise SystemExit

if len(sys.argv) > 2:
print("Too many arguments")
raise SystemExit

originalPicture = pathlib.Path(sys.argv[1])
if not (originalPicture.is_file()):
print(f"There is no such file: {sys.argv[1]}")
raise SystemExit

# if False, then sips will be used instead of ImageMagick
useMagick = True

fname = pathlib.Path(originalPicture).stem
ext = pathlib.Path(originalPicture).suffix
destDir = pathlib.Path(originalPicture).parent

iconsetDir = pathlib.Path(destDir / f"{fname}.iconset")
if not (iconsetDir.is_dir()):
pathlib.Path(iconsetDir).mkdir(parents=False, exist_ok=True)


class IconParameters():
width = 0
scale = 1

def __init__(self, width, scale):
self.width = width
self.scale = scale

def getIconName(self):
if self.scale != 1:
return f"icon_{self.width}x{self.width}{ext}"
else:
return f"icon_{self.width//2}x{self.width//2}@2x{ext}"


# https://developer.apple.com/design/human-interface-guidelines/macos/icons-and-images/app-icon#app-icon-sizes
ListOfIconParameters = [
IconParameters(16, 1),
IconParameters(16, 2),
IconParameters(32, 1),
IconParameters(32, 2),
IconParameters(64, 1),
IconParameters(64, 2),
IconParameters(128, 1),
IconParameters(128, 2),
IconParameters(256, 1),
IconParameters(256, 2),
IconParameters(512, 1),
IconParameters(512, 2),
IconParameters(1024, 1),
IconParameters(1024, 2)
]

# generate iconset
for ip in ListOfIconParameters:
if useMagick:
subprocess.call(
[
"magick",
"convert",
originalPicture,
"-resize",
str(ip.width),
iconsetDir / ip.getIconName()
]
)
else:
subprocess.call(
[
"sips",
"-z",
str(ip.width),
str(ip.width),
originalPicture,
"--out",
iconsetDir / ip.getIconName()
]
)
#print(f"Generated {ip.getIconName()}")

# convert iconset to icns file
subprocess.call(
[
"iconutil",
"-c",
"icns",
iconsetDir,
"-o",
destDir / f"{fname}.icns"
]
)
Binary file added support/pdfform2csv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 132 additions & 0 deletions support/pdfform2csv.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5a4121a

Please sign in to comment.