inkscape
This commit is contained in:
parent
0dc0b7dc9b
commit
15a2e4d070
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -160,3 +160,4 @@ cython_debug/
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
labels/
|
56
README.md
56
README.md
|
@ -2,12 +2,56 @@
|
||||||
|
|
||||||
fancy name, QL-570 text formater
|
fancy name, QL-570 text formater
|
||||||
|
|
||||||
using gpt i got a shell script and then a python one. the python tries to detect letter width and maximise it to fit the label printer constraints (62mm width)
|
|
||||||
|
|
||||||
TDLR
|
### TODO
|
||||||
`sudo brother_ql -b pyusb --model QL-570 -p usb://0x04f9:0x2028/000M12345678 print -l 62 logo.png`
|
|
||||||
|
|
||||||
TODO:
|
|
||||||
- use as printer
|
- use as printer
|
||||||
- fix missing font defentions fail to take into account letter width
|
- works, but cant detect the length of text, will output a set (page?) length
|
||||||
|
- fix missing font defentions
|
||||||
|
- fail to take into account letter width
|
||||||
- telegram bot (!)
|
- telegram bot (!)
|
||||||
|
|
||||||
|
## CLI
|
||||||
|
`sudo brother_ql -b pyusb --model QL-570 -p usb://0x04f9:0x2028/000M12345678 print -l 62 logo.png`
|
||||||
|
## python
|
||||||
|
python tries to detect letter width and maximise it to fit the label printer constraints (62mm width)
|
||||||
|
`python thermatext.py "label to print"`
|
||||||
|
|
||||||
|
## inkscape
|
||||||
|
[gptgist](https://gist.github.com/5shekel/98cc4898a1a8c7a5a1b305acc01d4326)
|
||||||
|
|
||||||
|
inskcape user extension path
|
||||||
|
`/home/${USER}/.config/inkscape/extensions`
|
||||||
|
|
||||||
|
symbolic link the dir fro here to the inkscape extension
|
||||||
|
`ln -s /home/${USER}/yair/thermatext/inkscape /home/${USER}/.config/inkscape/extensions/thermatext`
|
||||||
|
then check
|
||||||
|
```bash
|
||||||
|
find ~/.config/inkscape/ -type l
|
||||||
|
```
|
||||||
|
|
||||||
|
takes from the [inkscape-silhouette](https://github.com/fablabnbg/inkscape-silhouette) extension, as in, how to install.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git clone https://github.com/fablabnbg/inkscape-silhouette
|
||||||
|
Cloning into 'inkscape-silhouette'...
|
||||||
|
remote: Enumerating objects: 2764, done.
|
||||||
|
remote: Counting objects: 100% (795/795), done.
|
||||||
|
remote: Compressing objects: 100% (364/364), done.
|
||||||
|
remote: Total 2764 (delta 483), reused 657 (delta 416), pack-reused 1969
|
||||||
|
Receiving objects: 100% (2764/2764), 8.53 MiB | 3.64 MiB/s, done.
|
||||||
|
Resolving deltas: 100% (1786/1786), done.
|
||||||
|
|
||||||
|
$ cd inkscape-silhouette/
|
||||||
|
|
||||||
|
$ make install-local
|
||||||
|
|
||||||
|
mkdir -p locale
|
||||||
|
mkdir -p /home/devdesk/.config/inkscape/extensions
|
||||||
|
cp -r silhouette /home/devdesk/.config/inkscape/extensions
|
||||||
|
install -m 755 *silhouette*.py /home/devdesk/.config/inkscape/extensions
|
||||||
|
install -m 644 *.inx /home/devdesk/.config/inkscape/extensions
|
||||||
|
cp -r locale /home/devdesk/.config/inkscape/extensions
|
||||||
|
mkdir -p /home/devdesk/.config/inkscape/templates
|
||||||
|
install -m 644 templates/*.svg /home/devdesk/.config/inkscape/templates
|
||||||
|
|
||||||
|
```
|
2
inkscape/print.sh
Normal file
2
inkscape/print.sh
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
sudo brother_ql -b pyusb --model QL-570 -p usb://0x04f9:0x2028/000M6Z401370 print -l 62 ~/text285.png
|
13
inkscape/thermo.inx
Normal file
13
inkscape/thermo.inx
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||||
|
<_name>therma</_name>
|
||||||
|
<id>org.inkscape.effect.exportandrunscript</id>
|
||||||
|
<dependency type="executable" location="extensions">thermatext/thermo.py</dependency>
|
||||||
|
<effect>
|
||||||
|
<object-type>all</object-type>
|
||||||
|
</effect>
|
||||||
|
<script>
|
||||||
|
<command reldir="extensions" interpreter="python">thermatext/thermo.py</command>
|
||||||
|
</script>
|
||||||
|
<category>Fx</category>
|
||||||
|
</inkscape-extension>
|
49
inkscape/thermo.py
Normal file
49
inkscape/thermo.py
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import inkex
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
class ExportAndRunScript(inkex.EffectExtension):
|
||||||
|
|
||||||
|
def effect(self):
|
||||||
|
# Define the export file path
|
||||||
|
png_file_path = "~/yair/exported.png"
|
||||||
|
|
||||||
|
# Get the current selection
|
||||||
|
selection = self.svg.selected
|
||||||
|
|
||||||
|
# If there's no selection, show an error and exit
|
||||||
|
if not selection:
|
||||||
|
inkex.dialogs.errormsg("No selection to export.")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Export the selection to PNG
|
||||||
|
self.export_selection_to_png(selection, png_file_path)
|
||||||
|
|
||||||
|
# Run the bash script on the exported PNG
|
||||||
|
self.run_script_on_png(png_file_path)
|
||||||
|
|
||||||
|
def export_selection_to_png(self, selection, png_file_path):
|
||||||
|
# Create a command that calls Inkscape's command line interface to export the selection to a PNG
|
||||||
|
command = ["inkscape", "--export-area-drawing", "--export-dpi=96", "--export-background-opacity=0", "-o", "{}".format(png_file_path)]
|
||||||
|
|
||||||
|
# Add the IDs of the selected items to the command
|
||||||
|
for id, item in selection.items():
|
||||||
|
command.append("--export-id={}".format(id))
|
||||||
|
|
||||||
|
# Run the command
|
||||||
|
subprocess.check_call(command)
|
||||||
|
|
||||||
|
def run_script_on_png(self, png_file_path):
|
||||||
|
# Define the path to your bash script
|
||||||
|
bash_script_path = "print.sh"
|
||||||
|
|
||||||
|
# Create a command that calls the bash script with the PNG as an argument
|
||||||
|
command = ["bash", bash_script_path, png_file_path]
|
||||||
|
|
||||||
|
# Run the command
|
||||||
|
subprocess.check_call(command)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
ExportAndRunScript().run()
|
Loading…
Reference in New Issue
Block a user