Our logo is designed in a Keynote document. This is nice, but annoyingly Keynote cannot export png's with alpha transparency.

The first page of the Keynote document is a pure black and white version of the logo. We load this using Menpo, and use Pillow to export a PNG with alpha transparency.


In [ ]:
import numpy as np
import menpo
from PIL import Image as PILImage

dark_blue = (10, 78, 178)  # use the blue we use in the landmarker.io UI

# import the png export from Keynote
i = menpo.io.import_image('./landmarkerio_logo/landmarkerio_logo.001.png')
i.pixels = i.pixels[:3]
alpha = ((1 - i.as_greyscale(mode='average').pixels) * 255).astype(np.uint8)[0]

pixels = np.zeros(alpha.shape + (4,), dtype=np.uint8)
pixels[..., 3] = alpha
pixels[..., :3] = dark_blue

pil_image = PILImage.fromarray(pixels)

In [ ]:
pil_image.save('./landmarker_with_alpha.png')