Attachment deleted - it was a failed attempt to create a plugin.
For me, it works well.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This plugin is based on:
# Zint Barcode Generator 2.4.3 https://sourceforge.net/projects/zint/?source=navbar
# Resize with ImageMagick.py V1 - (c) Berthold Hinz 2010
# ==============================================================================
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ==============================================================================
from gimpfu import *
import shlex
import subprocess
import os, sys
import tempfile
def barcode(img, layer, type, format, path1, path2, height, space, border, fg, text, rem):
pdb.gimp_image_undo_group_start(img)
tempimage = pdb.gimp_image_duplicate(img)
if format=="png":
tempfilename = pdb.gimp_temp_name("png")
else:
tempfilename = pdb.gimp_temp_name("svg")
tempdrawable = pdb.gimp_image_get_active_drawable(tempimage)
pdb.gimp_progress_set_text ("Saving a copy")
if format=="png":
pdb.gimp_file_save(tempimage, tempdrawable, tempfilename, "")
else:
pdb.gimp_vectors_export_to_file(tempimage, tempfilename, None)
cmd="zint "
cmd=cmd+ "-o"+tempfilename + " -b "+str(type) + " --height="+str(height) + " -w"+str(space) + " --box --border="+str(border) + " --fg="+str(fg) + " -d "+'"'+str(text)+'"'
args = shlex.split(cmd)
p = os.popen(cmd)
pdb.gimp_progress_set_text ("calling Zint 2.4.3...")
pdb.gimp_progress_pulse()
child = subprocess.Popen(args, shell=False)
child.communicate()
newlayer = pdb.gimp_file_load_layer(img, tempfilename)
img.add_layer(newlayer,-1)
if format=="svg":
pdb.gimp_vectors_import_from_file(img, tempfilename, path1, path2)
if rem:
os.remove(tempfilename)
gimp.delete(tempimage)
pdb.gimp_image_undo_group_end(img)
gimp.displays_flush()
register(
"python-fu-barcode",
"Barcode Zint for GIMP\n\nNUMERIC VALUE - Barcode Name:\n\n 9 - Extended Code\n 20 - Code 128\n 23 - Code 16K\n 24 - Code 49\n 25 - Code 93\n 35 - Telpen Alpha\n 57 - Maxicode\n 58 - QR Code\n 71 - Data Matrix\n 84 - MicroPDF417\n 92 - Aztec Code\n 97 - Micro QR Code\n141 - Code One\n142 - Grid Matrix",
"Barcode based by Zint v.2.0",
"MareroQ",
"GPL",
"2016",
"<Image>/Filters/Render/Barcode Zint...",
"",
[
(PF_INT, "type", ("Type barcode (numeric value) :"), "20"),
(PF_RADIO, "format", ("Format barcode (temp) :"), "png", (("PNG", "png"),("SVG :", "svg"))),
(PF_BOOL, "path1", "Merge paths into a single vectors object : ", False),
(PF_BOOL, "path2", "Scale the SVG to image dimensions : ", False),
(PF_INT, "height", ("Adjusting height :"), "10"),
(PF_INT, "space", ("Adjusting whitespace (left and right) :"), "0"),
(PF_INT, "border", ("Adding boundary bars and boxes :"), "0"),
(PF_STRING, "fg", "Color FG (HTML):", "000000"),
(PF_STRING, "text", "Text (only Latin-1) :", "Test123"),
(PF_BOOL, "rem_1", ("Delete temp file? "), True)
],
[],
barcode)
main()