Skip to content

Instantly share code, notes, and snippets.

@y-yu
Last active August 29, 2015 14:17
Show Gist options
  • Save y-yu/97119fa45d5bf5c54d45 to your computer and use it in GitHub Desktop.
Save y-yu/97119fa45d5bf5c54d45 to your computer and use it in GitHub Desktop.
OS Xのマウスポインターを半透明にする ref: http://qiita.com/yyu/items/5cc554f26dddc1c1b5d5
from base64 import decodestring, encodestring
from xml.etree.ElementTree import ElementTree
import sys
import io
from PIL import Image
inputfile = sys.argv[1].strip()
outputfile = sys.argv[2].strip()
opacity = sys.argv[3].strip()
tree = ElementTree()
tree.parse(inputfile)
imagedata = tree.findall("dict/dict/dict/array/data")
for i in imagedata:
img = decodestring(i.text)
img = Image.open(io.BytesIO(img))
img = img.convert('RGBA')
data = img.getdata()
new = []
for p in data:
new.append((p[0], p[1], p[2], int(p[3] * opacity)))
img.putdata(new)
img.save('temp.png', 'PNG')
result = open('temp.png', 'r')
base64 = encodestring(result.read())
result.close()
i.text = base64
tree.write(outputfile)
$ pip install Pillow
$ python convert.py /path/to/dumpfile.cape output.cape 0.5
tell application "Mousecape"
activate
end tell
delay 0.1
tell application "System Events" to tell application process "Mousecape"
click (menu item 3 of menu 1 of menu bar item 2 of menu bar 1)
set theSlider to slider 1 of window 1
set value of theSlider to 3.0
end tell
quit application "Mousecape"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment