fixed output pro extension
This commit is contained in:
parent
420f22c4d0
commit
873c52130d
extensions/fablabchemnitz
BIN
extensions/fablabchemnitz/boxes.py/SlatwallCaliper-thumb.jpg
Normal file
BIN
extensions/fablabchemnitz/boxes.py/SlatwallCaliper-thumb.jpg
Normal file
Binary file not shown.
After (image error) Size: 37 KiB |
BIN
extensions/fablabchemnitz/boxes.py/SlatwallDrillBox-thumb.jpg
Normal file
BIN
extensions/fablabchemnitz/boxes.py/SlatwallDrillBox-thumb.jpg
Normal file
Binary file not shown.
After (image error) Size: 28 KiB |
Binary file not shown.
After (image error) Size: 36 KiB |
Binary file not shown.
After (image error) Size: 29 KiB |
BIN
extensions/fablabchemnitz/boxes.py/SlatwallTypeTray-thumb.jpg
Normal file
BIN
extensions/fablabchemnitz/boxes.py/SlatwallTypeTray-thumb.jpg
Normal file
Binary file not shown.
After (image error) Size: 23 KiB |
@ -854,31 +854,37 @@ class OutputProBitmap(inkex.EffectExtension):
|
||||
self.generate_preview()
|
||||
|
||||
def cmyk_overprint_black(self):
|
||||
if self.cmyk_overblack_jpeg.isChecked():
|
||||
cmyk.generate_svg_separations(dirpathTempFolder.name, open(os.path.join(dirpathTempFolder.name, 'original.svg')).read(), True)
|
||||
else:
|
||||
cmyk.generate_svg_separations(dirpathTempFolder.name, open(os.path.join(dirpathTempFolder.name, 'original.svg')).read(), False)
|
||||
with open(os.path.join(dirpathTempFolder.name, 'original.svg'), 'r') as f:
|
||||
if self.cmyk_overblack_jpeg.isChecked():
|
||||
cmyk.generate_svg_separations(dirpathTempFolder.name, f.read(), True)
|
||||
else:
|
||||
cmyk.generate_svg_separations(dirpathTempFolder.name, f.read(), False)
|
||||
|
||||
def cmyk_advanced_manipulation(self):
|
||||
area_to_export = self.area_to_export()
|
||||
cmyk.generate_png_separations(dirpathTempFolder.name, self.area_to_export(), self.dpi_choice.value(), False)
|
||||
|
||||
for color in ['C', 'M', 'Y', 'K']:
|
||||
subprocess.Popen(
|
||||
['convert',
|
||||
cmd = ['convert',
|
||||
os.path.join(dirpathTempFolder.name, 'separated' + area_to_export.replace(' ', '') + color + ".png"),
|
||||
'-colorspace', 'CMYK', '-channel',
|
||||
'-colorspace',
|
||||
'CMYK',
|
||||
'-channel',
|
||||
color,
|
||||
'-separate',
|
||||
os.path.join(dirpathTempFolder.name, 'separated' + area_to_export.replace(' ', '') + color + ".png")]
|
||||
).wait()
|
||||
|
||||
#inkex.utils.debug(cmd)
|
||||
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
p.wait()
|
||||
#if p.returncode != 0:
|
||||
# inkex.utils.debug("Command failed: %d %s %s" % (p.returncode, stdout, stderr))
|
||||
self.cmyk_advanced_manipulation_view_separations()
|
||||
|
||||
def cmyk_advanced_manipulation_view_separations(self):
|
||||
area_to_export = self.area_to_export()
|
||||
|
||||
file_info = subprocess.Popen(['identify', os.path.join(dirpathTempFolder.name, 'source.svg')], stdout=subprocess.PIPE).communicate()[0].decode('UTF-8')
|
||||
file_info = subprocess.Popen(['identify', os.path.join(dirpathTempFolder.name, 'source.png')], stdout=subprocess.PIPE).communicate()[0].decode('UTF-8')
|
||||
|
||||
image_size = file_info.split(' ')[2]
|
||||
|
||||
@ -887,24 +893,24 @@ class OutputProBitmap(inkex.EffectExtension):
|
||||
final_command = ['convert']
|
||||
|
||||
if self.view_c_button.isChecked():
|
||||
final_command.append( os.path.join(dirpathTempFolder.name, 'separated') + area_to_export.replace(' ', '') + 'C' + ".png")
|
||||
final_command.append(os.path.join(dirpathTempFolder.name, 'separated') + area_to_export.replace(' ', '') + 'C' + ".png")
|
||||
else:
|
||||
final_command.append( os.path.join(dirpathTempFolder.name, 'empty.pn'))
|
||||
final_command.append(os.path.join(dirpathTempFolder.name, 'empty.png'))
|
||||
|
||||
if self.view_m_button.isChecked():
|
||||
final_command.append( os.path.join(dirpathTempFolder.name, 'separated') + area_to_export.replace(' ', '') + 'M' + ".png")
|
||||
final_command.append(os.path.join(dirpathTempFolder.name, 'separated') + area_to_export.replace(' ', '') + 'M' + ".png")
|
||||
else:
|
||||
final_command.append( os.path.join(dirpathTempFolder.name, 'empty.png'))
|
||||
final_command.append(os.path.join(dirpathTempFolder.name, 'empty.png'))
|
||||
|
||||
if self.view_y_button.isChecked():
|
||||
final_command.append( os.path.join(dirpathTempFolder.name, 'separated') + area_to_export.replace(' ', '') + 'Y' + ".png")
|
||||
final_command.append(os.path.join(dirpathTempFolder.name, 'separated') + area_to_export.replace(' ', '') + 'Y' + ".png")
|
||||
else:
|
||||
final_command.append( os.path.join(dirpathTempFolder.name, 'empty.png'))
|
||||
final_command.append(os.path.join(dirpathTempFolder.name, 'empty.png'))
|
||||
|
||||
if self.view_k_button.isChecked():
|
||||
final_command.append( os.path.join(dirpathTempFolder.name, 'separated') + area_to_export.replace(' ', '') + 'K' + ".png")
|
||||
final_command.append(os.path.join(dirpathTempFolder.name, 'separated') + area_to_export.replace(' ', '') + 'K' + ".png")
|
||||
else:
|
||||
final_command.append( os.path.join(dirpathTempFolder.name, 'empty.png'))
|
||||
final_command.append(os.path.join(dirpathTempFolder.name, 'empty.png'))
|
||||
|
||||
final_command.extend(['-set', 'colorspace', 'cmyk'])
|
||||
final_command.extend(['-combine', os.path.join(dirpathTempFolder.name, 'result.tiff')])
|
||||
@ -1049,6 +1055,7 @@ class OutputProBitmap(inkex.EffectExtension):
|
||||
except Exception as e:
|
||||
self.msg(e)
|
||||
finally:
|
||||
#inkex.utils.debug(os.listdir(dirpathTempFolder.name))
|
||||
dirpathTempFolder.cleanup() #close temp dir
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import re, subprocess, simplestyle, os
|
||||
import re, subprocess, os
|
||||
import inkex
|
||||
from inkex.command import inkscape
|
||||
|
||||
def calculateCMYK(red, green, blue):
|
||||
C = float()
|
||||
@ -27,8 +28,8 @@ def calculateCMYK(red, green, blue):
|
||||
def clean_svg_color_definitions(svg):
|
||||
def change_colors(origin, color_type):
|
||||
for i in range(len(str(origin).split(color_type + ':'))):
|
||||
if str(str(origin).split(color_type + ':')[i].split(';')[0]) in simplestyle.svgcolors.keys():
|
||||
color_numbers = simplestyle.formatColoria(simplestyle.parseColor(str(str(origin).split(color_type + ':')[i].split(';')[0])))
|
||||
if str(str(origin).split(color_type + ':')[i].split(';')[0]) in inkex.colors.SVG_COLOR.keys():
|
||||
color_numbers = str(inkex.Color(inkex.Color(str(str(origin).split(color_type + ':')[i].split(';')[0])).to_rgb()))
|
||||
origin = str(origin).replace(':' + str(str(origin).split(color_type + ':')[i].split(';')[0]) + ';', ':' + color_numbers + ';')
|
||||
return origin
|
||||
|
||||
@ -47,42 +48,42 @@ def removeK(origin):
|
||||
def representC(value):
|
||||
# returns CMS color if available
|
||||
if (re.search("icc-color", value.group())):
|
||||
return simplestyle.formatColor3f(float(1.00 - float(re.split(r'[,\)\s]+',value.group())[2])), float(1.00), float(1.00))
|
||||
return str(inkex.Color((float(1.00 - float(re.split(r'[,\)\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))
|
||||
red = float(inkex.Color(str(value.group())).to_rgb()[0]/255.00)
|
||||
green = float(inkex.Color(str(value.group())).to_rgb()[1]/255.00)
|
||||
blue = float(inkex.Color(str(value.group())).to_rgb()[2]/255.00)
|
||||
return str(inkex.Color((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(r'[,\)\s]+',value.group())[3])), float(1.00))
|
||||
return str(inkex.Color((float(1.00), float(1.00 - float(re.split(r'[,\)\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))
|
||||
red = float(inkex.Color(str(value.group())).to_rgb()[0]/255.00)
|
||||
green = float(inkex.Color(str(value.group())).to_rgb()[1]/255.00)
|
||||
blue = float(inkex.Color(str(value.group())).to_rgb()[2]/255.00)
|
||||
return str(inkex.Color((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(r'[,\)\s]+',value.group())[4])))
|
||||
return str(inkex.Color((float(1.00), float(1.00), float(1.00 - float(re.split(r'[,\)\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]))
|
||||
red = float(inkex.Color(str(value.group())).to_rgb()[0]/255.00)
|
||||
green = float(inkex.Color(str(value.group())).to_rgb()[1]/255.00)
|
||||
blue = float(inkex.Color(str(value.group())).to_rgb()[2]/255.00)
|
||||
return str(inkex.Color((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(r'[,\)\s]+',value.group())[5])), float(1.00 - float(re.split(r'[,\)\s]+',value.group())[5])), float(1.00 - float(re.split(r'[,\)\s]+',value.group())[5])))
|
||||
return str(inkex.Color((float(1.00 - float(re.split(r'[,\)\s]+',value.group())[5])), float(1.00 - float(re.split(r'[,\)\s]+',value.group())[5])), float(1.00 - float(re.split(r'[,\)\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]))
|
||||
red = float(inkex.Color(str(value.group())).to_rgb()[0]/255.00)
|
||||
green = float(inkex.Color(str(value.group())).to_rgb()[1]/255.00)
|
||||
blue = float(inkex.Color(str(value.group())).to_rgb()[2]/255.00)
|
||||
return str(inkex.Color((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):
|
||||
@ -105,13 +106,12 @@ def generate_png_separations(temp_dir, area_to_export, resolution, alpha):
|
||||
if alpha:
|
||||
alpha_command = ""
|
||||
else:
|
||||
alpha_command = " --export-background=white "
|
||||
string_inkscape_exec = ''
|
||||
alpha_command = ";export-background:white"
|
||||
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"
|
||||
|
||||
with open(os.path.join(temp_dir, 'test.txt'), 'w') as f:
|
||||
f.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.encode('UTF-8'))
|
||||
cmd = area_to_export + alpha_command + ';export-dpi:' + str(resolution) + ';export-background-opacity:1;export-filename:' + os.path.join(temp_dir, "separated" + area_to_export.replace(' ', '') + color + ".png") + ';export-do'
|
||||
#inkex.utils.debug(cmd)
|
||||
cli_output = inkscape(os.path.join(temp_dir, "separation" + color + ".svg"), actions=cmd)
|
||||
if len(cli_output) > 0:
|
||||
inkex.utils.debug(cli_output)
|
||||
#inkex.utils.debug(os.listdir(temp_dir))
|
||||
|
Reference in New Issue
Block a user