added output pro extension. not working yet. working on ...

This commit is contained in:
Mario Voigt 2021-04-29 15:53:03 +02:00
parent 4086288044
commit 5ba9ac7846
8 changed files with 1247 additions and 0 deletions

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Inkscape Output Pro</name>
<id>fablabchemnitz.de.output_pro</id>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="FabLab Chemnitz">
<submenu name="Import/Export/Transfer"/>
</submenu>
</effects-menu>
</effect>
<script>
<command location="inx" interpreter="python">outputpro.py</command>
</script>
</inkscape-extension>

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

View File

@ -0,0 +1,115 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re, subprocess, simplestyle, os#inkex, os, random, sys, subprocess, shutil
def calculateCMYK(red, green, blue):
C = float()
M = float()
Y = float()
K = float()
if 1.00 - red < 1.00 - green:
K = 1.00 - red
else:
K = 1.00 - green
if 1.00 - blue < K:
K = 1.00 - blue
if K != 1.00:
C = ( 1.00 - red - K ) / ( 1.00 - K )
M = ( 1.00 - green - K ) / ( 1.00 - K )
Y = ( 1.00 - blue - K ) / ( 1.00 - K )
return [C, M, Y, K]
def clean_svg_color_definitions(svg):
def change_colors(origin, tipo_cor):
for i in range(len(str(origin).split(tipo_cor + ':'))):
if str(str(origin).split(tipo_cor + ':')[i].split(';')[0]) in simplestyle.svgcolors.keys():
numeros_da_cor = simplestyle.formatColoria(simplestyle.parseColor(str(str(origin).split(tipo_cor + ':')[i].split(';')[0])))
origin = str(origin).replace(':' + str(str(origin).split(tipo_cor + ':')[i].split(';')[0]) + ';', ':' + numeros_da_cor + ';')
return origin
colortypes = ['fill', 'stop-color', 'flood-color', 'lighting-color', 'stroke']
for i in range(len(colortypes)):
svg = change_colors(svg, colortypes[i])
return svg
def removeK(origem):
def zerar_opacidade(valor):
return str(valor.group()).split('opacity:')[0] + "opacity:0;"
#return re.sub("#000000;fill-opacity:[0-9.]+;", zerar_opacidade, re.sub("#000000;stop-opacity:[0-9.]+;", zerar_opacidade, re.sub("#000000;stroke-opacity:[0-9.]+;", zerar_opacidade, re.sub("#000000;flood-opacity:[0-9.]+;", zerar_opacidade, re.sub("#000000;lighting-opacity:[0-9.]+;", zerar_opacidade, origem)))))
return re.sub("#000000;fill-opacity:[0-9.?]+", zerar_opacidade, re.sub("#000000;stop-opacity:[0-9.?]+", zerar_opacidade, re.sub("#000000;stroke-opacity:[0-9.?]+", zerar_opacidade, re.sub("#000000;flood-opacity:[0-9.?]+", zerar_opacidade, re.sub("#000000;lighting-opacity:[0-9.?]+", zerar_opacidade, origem)))))
def representC(value):
# returns CMS color if available
if (re.search("icc-color", value.group()) ):
return simplestyle.formatColor3f(float(1.00 - float(re.split('[,\)\s]+',value.group())[2])), float(1.00), float(1.00))
else:
red = float(simplestyle.parseColor(str(value.group()))[0]/255.00)
green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
blue = float(simplestyle.parseColor(str(value.group()))[2]/255.00)
return simplestyle.formatColor3f(float(1.00 - calculateCMYK(red, green, blue)[0]), float(1.00), float(1.00))
def representM(value):
# returns CMS color if available
if ( re.search("icc-color", value.group()) ):
return simplestyle.formatColor3f(float(1.00), float(1.00 - float(re.split('[,\)\s]+',value.group())[3])), float(1.00))
else:
red = float(simplestyle.parseColor(str(value.group()))[0]/255.00)
green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
blue = float(simplestyle.parseColor(str(value.group()))[2]/255.00)
return simplestyle.formatColor3f(float(1.00), float(1.00 - calculateCMYK(red, green, blue)[1]), float(1.00))
def representY(value):
# returns CMS color if available
if (re.search("icc-color", value.group()) ):
return simplestyle.formatColor3f(float(1.00), float(1.00), float(1.00 - float(re.split('[,\)\s]+',value.group())[4])))
else:
red = float(simplestyle.parseColor(str(value.group()))[0]/255.00)
green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
blue = float(simplestyle.parseColor(str(value.group()))[2]/255.00)
return simplestyle.formatColor3f(float(1.00), float(1.00), float(1.00 - calculateCMYK(red, green, blue)[2]))
def representK(value):
# returns CMS color if available
if (re.search("icc-color", value.group()) ):
return simplestyle.formatColor3f(float(1.00 - float(re.split('[,\)\s]+',value.group())[5])), float(1.00 - float(re.split('[,\)\s]+',value.group())[5])), float(1.00 - float(re.split('[,\)\s]+',value.group())[5])))
else:
red = float(simplestyle.parseColor(str(value.group()))[0]/255.00)
green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
blue = float(simplestyle.parseColor(str(value.group()))[2]/255.00)
return simplestyle.formatColor3f(float(1.00 - calculateCMYK(red, green, blue)[3]), float(1.00 - calculateCMYK(red, green, blue)[3]), float(1.00 - calculateCMYK(red, green, blue)[3]))
def generate_svg_separations(temp_dir, original_source, overblack):
svg_ready = clean_svg_color_definitions(original_source)
open(temp_dir + "separationK.svg","w").write(re.sub("#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representK, svg_ready))
if overblack:
svg_ready = removeK(svg_ready)
open(temp_dir + "separationC.svg","w").write(re.sub("#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representC, svg_ready))
open(temp_dir + "separationM.svg","w").write(re.sub("#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representM, svg_ready))
open(temp_dir + "separationY.svg","w").write(re.sub("#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representY, svg_ready))
def generate_png_separations(temp_dir, area_to_export, resolution, alpha):
if alpha:
alpha_command = ""
else:
alpha_command = " --export-background=white "
string_inkscape_exec = ''
for color in ['C', 'M', 'Y', 'K']:
string_inkscape_exec += temp_dir + "separation" + color + ".svg " + area_to_export + ' --export-png=' + temp_dir + "separated" + area_to_export.replace(' ', '') + color + ".png" + alpha_command + ' --export-dpi=' + str(resolution) + "\n"
open('/tmp/teste.txt', 'w').write(string_inkscape_exec)
inkscape_exec = subprocess.Popen(['inkscape -z --shell'], shell=True, stdout=open(os.devnull, 'w'), stderr=open(os.devnull, 'w'), stdin=subprocess.PIPE)
inkscape_exec.communicate(input=string_inkscape_exec)

View File

@ -0,0 +1,82 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess #re, subprocess, simplestyle, os#inkex, os, random, sys, subprocess, shutil
def generate_final_file(isvector, hide_inside_marks, colormode, width, height, space, strokewidth, bleedsize, marksize, temp_dir):
if not isvector:
command = []
final_command = ['convert']
for color in colormode:
command.append('convert')
command.append('-size')
command.append(str(sum(width) + (marksize*2) + (space * (len(width) -1))) + 'x' + str(sum(height) + (marksize*2) + (space * (len(height) -1))))
command.append('xc:white')
command.append('-stroke')
command.append('black')
command.append('-strokewidth')
command.append(str(strokewidth))
width_value = 0
number_of_column = 1
for column in width:
height_value = 0
number_of_line = 1
for line in height:
open('/tmp/str.txt', 'a').write(str(width.index(column)))
if not hide_inside_marks or (hide_inside_marks and number_of_column == 1):
command.append('-draw')
command.append('line ' + str(width_value + marksize) + ',' + str(height_value + marksize + bleedsize) + ', ' + str(width_value) + ',' + str(height_value + marksize + bleedsize))
command.append('-draw')
command.append('line ' + str(width_value + marksize) + ',' + str(height_value + line + marksize - bleedsize) + ', ' + str(width_value) + ',' + str(height_value + line + marksize - bleedsize))
if not hide_inside_marks or (hide_inside_marks and number_of_line == 1):
command.append('-draw')
command.append('line ' + str(width_value + marksize + bleedsize) + ',' + str(height_value + marksize) + ', ' + str(width_value + marksize + bleedsize) + ',' + str(height_value))
command.append('-draw')
command.append('line ' + str(width_value + column + marksize - bleedsize) + ',' + str(height_value + marksize) + ', ' + str(width_value + column + marksize - bleedsize) + ',' + str(height_value))
if not hide_inside_marks or (hide_inside_marks and number_of_column == len(width)):
command.append('-draw')
command.append('line ' + str(width_value + marksize + column) + ',' + str(height_value + marksize + bleedsize) + ', ' + str(width_value + (marksize*2) + column) + ',' + str(height_value + marksize + bleedsize))
command.append('-draw')
command.append('line ' + str(width_value + marksize + column) + ',' + str(height_value + line + marksize - bleedsize) + ', ' + str(width_value + (marksize*2) + column) + ',' + str(height_value + marksize + line - bleedsize))
if not hide_inside_marks or (hide_inside_marks and number_of_line == len(height)):
command.append('-draw')
command.append('line ' + str(width_value + marksize + bleedsize) + ',' + str(height_value + line + marksize) + ', ' + str(width_value + marksize + bleedsize) + ',' + str(height_value + line + (marksize*2)))
command.append('-draw')
command.append('line ' + str(width_value + column + marksize - bleedsize) + ',' + str(height_value + line + marksize) + ', ' + str(width_value + marksize + column - bleedsize) + ',' + str(height_value + line + (marksize*2)))
height_value += line + space
number_of_line += 1
width_value += column + space
number_of_column += 1
command.append(temp_dir + '/cut_mark_' + color + '.png')
subprocess.Popen(command).wait()
del command[:]
command.append('convert')
command.append(temp_dir + '/cut_mark_' + color + '.png')
command.append('-colorspace')
command.append(str(colormode).lower())
command.append('-channel')
command.append('K')
command.append('-separate')
command.append(temp_dir + '/cut_mark_' + color + '.png')
subprocess.Popen(command).wait()
del command[:]
final_command.append(temp_dir + '/cut_mark_' + color + '.png')
final_command.extend(['-set', 'colorspace', colormode, '-combine', temp_dir + '/cut_mark.tiff'])
subprocess.Popen(final_command).wait()

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB