kle-scraper is a Python library for scraping the key top images of keyboard-layout-editor.com (KLE).
Project description
kle-scraper
kle-scraper is a Python library for scraping the key top images of keyboard-layout-editor.com (KLE).
It renders KLE screen by CEF (Chromium Embedded Framework) and captures it. It contains KLE codes and works offline, of course.
Limitations
- No support for custom styles. Key color is always white.
- Front legend is ignored.
- Legend color is equal to KLE screen, not the value in properties. KLE screen color is a bit paler than the value in properties.
- It handles non-rectangle keys (big ass enter and ISO enter) awkwardly. Big ass enter image lacks the left bottom bulge and ISO enter contains the left bottom dent.
- Crop area isn't pixel-wise precise, especially about rotated keys. The precision is half pixel in KLE screen.
- It is non-reentrant (not multi-threaded).
- It is slow, especially when the layout has a lot of differently rotated keys.
- It cannot handle extraordinary large layout.
Available platforms:
- Windows x86-64
- macOS Intel and Apple Silicon
- Linux x86-64 (aarch64 has a problem now in CEF. See: Dynamic loading of libcef.so on Linux ARM64 not possible anymore due to TLS size increase)
Installation
Grab your platform's wheel from cef-capi-py release and pip install it.
I haven't uploaded the wheels to PyPI yet because now PyPI project is not processing support issues:
File Limit Request: cef-capi-py - 180 MB.
pip install kle-scraper
Usage
import tempfile
from kle_scraper import scrape
with tempfile.TemporaryDirectory() as image_output_dir:
keyboard = scrape(kle_json_filename, image_output_dir)
You can find 0.png, 1.png and more in image_output_dir. The filename number corresponds to
keyboard.keys's index. keyboard is an instance of pykle_serial.Keyboard.
Otherwise from command line,
python -m kle_scraper {kle_json_filename} {image_output_dir}
Dimension of scraped images
Scraped images are magnified to 4x. On KLE screen, 1u key top has 42x42 px. Key layout pitch is 54x54 px. On scraped images, 1u key top (and image size) is 168x168 px and 1u pitch is 216x216 px.
License
MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kle_scraper-0.1.1-py3-none-any.whl.
File metadata
- Download URL: kle_scraper-0.1.1-py3-none-any.whl
- Upload date:
- Size: 649.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
844969d693dcccc434b053d099dc870367e50ab9a2d6b54501300cecd6b1f297
|
|
| MD5 |
7e5891abaa3510a29a92fe40a1199288
|
|
| BLAKE2b-256 |
d304a3d095508bc4f6573372852fdf312ff6c91ff91313eb7e2fed9430d3ba72
|