diff --git a/README.md b/README.md index 55337f3..50940e1 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,26 @@ On Arch Linux based distros you may install `bluez` first, as it may not be inst ```bash sudo pacman -S bluez bluez-utils ``` + +
+Further steps + +You may want to use the command line interface for hackiness... + +You may or may not need to install ImageMagick and Ghostscript, depending on your distro. + +```bash +sudo apt install imagemagick ghostscript +``` +or use your distro's package manager. + +Extra configuration is required for ImageMagick to work. Because IM is made for external webserver, a strict security policy is applied. You need to add the following line to `/etc/ImageMagick-6/policy.xml` before ``: +```xml + +``` + +Because this script is only accesible by localhost, or at most your local network, this is safe. +
*Packaging is also on the way!* diff --git a/printer.py b/printer.py index 16412c6..5d35a52 100644 --- a/printer.py +++ b/printer.py @@ -596,6 +596,9 @@ _MagickExe = fallback_program('magick', 'magick.exe', 'convert', 'convert.exe') def magick_text(stdin, image_width, font_size, font_family): 'Pipe an io to ImageMagick for processing text to image, return output io' read_fd, write_fd = os.pipe() + if _MagickExe is None: + fatal(i18n("imagemagick-not-found"), code=129) + subprocess.Popen([_MagickExe, '-background', 'white', '-fill', 'black', '-size', f'{image_width}x', '-font', font_family, '-pointsize', str(font_size), 'caption:@-', 'pbm:-'], @@ -605,6 +608,9 @@ def magick_text(stdin, image_width, font_size, font_family): def magick_image(stdin, image_width, dither): 'Pipe an io to ImageMagick for processing "usual" image to pbm, return output io' read_fd, write_fd = os.pipe() + if _MagickExe is None: + fatal(i18n("imagemagick-not-found"), code=129) + subprocess.Popen([_MagickExe, '-', '-fill', 'white', '-opaque', 'transparent', '-resize', f'{image_width}x', '-dither', dither, '-monochrome', 'pbm:-'], stdin=stdin, stdout=io.FileIO(write_fd, 'w')) diff --git a/www/lang/en-US.json b/www/lang/en-US.json index dd15e87..6da2fba 100644 --- a/www/lang/en-US.json +++ b/www/lang/en-US.json @@ -159,5 +159,7 @@ "test-unknown-device": "Test Unknown Device", "scan": "Scan", "now-will-scan-for-all-bluetooth-devices-nearby": "Scan set to search for all bluetooth devides nearby.", - "pf2-font-not-found-or-broken-0": "PF2 font not found or broken: '{0}'" + "pf2-font-not-found-or-broken-0": "PF2 font not found or broken: '{0}'", + "imagemagick-not-found": "ImageMagick not found, please install it and retry." + } \ No newline at end of file diff --git a/www/lang/lolcat.json b/www/lang/lolcat.json index b58e117..f898bf2 100644 --- a/www/lang/lolcat.json +++ b/www/lang/lolcat.json @@ -137,5 +137,7 @@ "test-unknown-device": "I HAV STRENGE KITTE", "now-will-scan-for-all-bluetooth-devices-nearby": "WIL FIND ALL THINY KITTE OR NOT", "scan": "FIND", - "pf2-font-not-found-or-broken-0": "KITTE FONT LOST OR DEAD> {0}" + "pf2-font-not-found-or-broken-0": "KITTE FONT LOST OR DEAD> {0}", + "image-magick-not-found": "IMAGEMAGICK NOT FINDZ, PLZ INSTALL IT AND HAVES ANODA GO." + } diff --git a/www/lang/zh-CN.json b/www/lang/zh-CN.json index 2b565ca..629b585 100644 --- a/www/lang/zh-CN.json +++ b/www/lang/zh-CN.json @@ -149,5 +149,6 @@ "javascript-catprinter-description": "猫咪打印机 (Cat-Printer) 主脚本", "free-software": "自由软件", "free-software-description": "尊重您计算自由的软件。", - "pf2-font-not-found-or-broken-0": "PF2 字体丢失或损坏:'{0}'" + "pf2-font-not-found-or-broken-0": "PF2 字体丢失或损坏:'{0}'", + "image-magick-not-found": "未找到 ImageMagick,请安装并重试。" } \ No newline at end of file diff --git a/www/lang/zh-HK.json b/www/lang/zh-HK.json index 77a71e7..d793ed6 100644 --- a/www/lang/zh-HK.json +++ b/www/lang/zh-HK.json @@ -149,5 +149,6 @@ "javascript-catprinter-description": "貓咪打印機 (Cat-Printer) 主腳本", "free-software": "自由軟件", "free-software-description": "尊重您計算自由的軟件。", - "pf2-font-not-found-or-broken-0": "PF2 字體丟失或損壞:'{0}'" + "pf2-font-not-found-or-broken-0": "PF2 字體丟失或損壞:'{0}'", + "imagemagick-not-found": "未找到 ImageMagick,請安裝並重試。" } \ No newline at end of file diff --git a/www/lang/zh-Hant-CN.json b/www/lang/zh-Hant-CN.json index b4f6eb5..1afb3a3 100644 --- a/www/lang/zh-Hant-CN.json +++ b/www/lang/zh-Hant-CN.json @@ -149,5 +149,6 @@ "javascript-catprinter-description": "貓咪打印機 (Cat-Printer) 主腳本", "free-software": "自由軟件", "free-software-description": "尊重您計算自由的軟件。", - "pf2-font-not-found-or-broken-0": "PF2 字體丟失或損壞:'{0}'" + "pf2-font-not-found-or-broken-0": "PF2 字體丟失或損壞:'{0}'", + "imagemagick-not-found": "未找到 ImageMagick,請安裝並重試。" } \ No newline at end of file diff --git a/www/lang/zh-TW.json b/www/lang/zh-TW.json index 02f946b..2081b97 100644 --- a/www/lang/zh-TW.json +++ b/www/lang/zh-TW.json @@ -149,5 +149,5 @@ "javascript-catprinter-description": "貓咪印表機 (Cat-Printer) 主指令碼", "free-software": "自由軟體", "free-software-description": "尊重您計算自由的軟體。", - "pf2-font-not-found-or-broken-0": "PF2 字型丟失或損壞:'{0}'" + "pf2-font-not-found-or-broken-0": "未找到 ImageMagick,請安裝並重試。" } \ No newline at end of file