fixed output pro extension
This commit is contained in:
parent
420f22c4d0
commit
873c52130d
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 Width: | Height: | 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 Width: | Height: | Size: 28 KiB |
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
Binary file not shown.
After Width: | Height: | 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 Width: | Height: | Size: 23 KiB |
@ -854,31 +854,37 @@ class OutputProBitmap(inkex.EffectExtension):
|
|||||||
self.generate_preview()
|
self.generate_preview()
|
||||||
|
|
||||||
def cmyk_overprint_black(self):
|
def cmyk_overprint_black(self):
|
||||||
|
with open(os.path.join(dirpathTempFolder.name, 'original.svg'), 'r') as f:
|
||||||
if self.cmyk_overblack_jpeg.isChecked():
|
if self.cmyk_overblack_jpeg.isChecked():
|
||||||
cmyk.generate_svg_separations(dirpathTempFolder.name, open(os.path.join(dirpathTempFolder.name, 'original.svg')).read(), True)
|
cmyk.generate_svg_separations(dirpathTempFolder.name, f.read(), True)
|
||||||
else:
|
else:
|
||||||
cmyk.generate_svg_separations(dirpathTempFolder.name, open(os.path.join(dirpathTempFolder.name, 'original.svg')).read(), False)
|
cmyk.generate_svg_separations(dirpathTempFolder.name, f.read(), False)
|
||||||
|
|
||||||
def cmyk_advanced_manipulation(self):
|
def cmyk_advanced_manipulation(self):
|
||||||
area_to_export = self.area_to_export()
|
area_to_export = self.area_to_export()
|
||||||
cmyk.generate_png_separations(dirpathTempFolder.name, self.area_to_export(), self.dpi_choice.value(), False)
|
cmyk.generate_png_separations(dirpathTempFolder.name, self.area_to_export(), self.dpi_choice.value(), False)
|
||||||
|
|
||||||
for color in ['C', 'M', 'Y', 'K']:
|
for color in ['C', 'M', 'Y', 'K']:
|
||||||
subprocess.Popen(
|
cmd = ['convert',
|
||||||
['convert',
|
|
||||||
os.path.join(dirpathTempFolder.name, 'separated' + area_to_export.replace(' ', '') + color + ".png"),
|
os.path.join(dirpathTempFolder.name, 'separated' + area_to_export.replace(' ', '') + color + ".png"),
|
||||||
'-colorspace', 'CMYK', '-channel',
|
'-colorspace',
|
||||||
|
'CMYK',
|
||||||
|
'-channel',
|
||||||
color,
|
color,
|
||||||
'-separate',
|
'-separate',
|
||||||
os.path.join(dirpathTempFolder.name, 'separated' + area_to_export.replace(' ', '') + color + ".png")]
|
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()
|
self.cmyk_advanced_manipulation_view_separations()
|
||||||
|
|
||||||
def cmyk_advanced_manipulation_view_separations(self):
|
def cmyk_advanced_manipulation_view_separations(self):
|
||||||
area_to_export = self.area_to_export()
|
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]
|
image_size = file_info.split(' ')[2]
|
||||||
|
|
||||||
@ -889,7 +895,7 @@ class OutputProBitmap(inkex.EffectExtension):
|
|||||||
if self.view_c_button.isChecked():
|
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:
|
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():
|
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")
|
||||||
@ -1049,6 +1055,7 @@ class OutputProBitmap(inkex.EffectExtension):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.msg(e)
|
self.msg(e)
|
||||||
finally:
|
finally:
|
||||||
|
#inkex.utils.debug(os.listdir(dirpathTempFolder.name))
|
||||||
dirpathTempFolder.cleanup() #close temp dir
|
dirpathTempFolder.cleanup() #close temp dir
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import re, subprocess, simplestyle, os
|
import re, subprocess, os
|
||||||
import inkex
|
import inkex
|
||||||
|
from inkex.command import inkscape
|
||||||
|
|
||||||
def calculateCMYK(red, green, blue):
|
def calculateCMYK(red, green, blue):
|
||||||
C = float()
|
C = float()
|
||||||
@ -27,8 +28,8 @@ def calculateCMYK(red, green, blue):
|
|||||||
def clean_svg_color_definitions(svg):
|
def clean_svg_color_definitions(svg):
|
||||||
def change_colors(origin, color_type):
|
def change_colors(origin, color_type):
|
||||||
for i in range(len(str(origin).split(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():
|
if str(str(origin).split(color_type + ':')[i].split(';')[0]) in inkex.colors.SVG_COLOR.keys():
|
||||||
color_numbers = simplestyle.formatColoria(simplestyle.parseColor(str(str(origin).split(color_type + ':')[i].split(';')[0])))
|
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 + ';')
|
origin = str(origin).replace(':' + str(str(origin).split(color_type + ':')[i].split(';')[0]) + ';', ':' + color_numbers + ';')
|
||||||
return origin
|
return origin
|
||||||
|
|
||||||
@ -47,42 +48,42 @@ def removeK(origin):
|
|||||||
def representC(value):
|
def representC(value):
|
||||||
# returns CMS color if available
|
# returns CMS color if available
|
||||||
if (re.search("icc-color", value.group())):
|
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:
|
else:
|
||||||
red = float(simplestyle.parseColor(str(value.group()))[0]/255.00)
|
red = float(inkex.Color(str(value.group())).to_rgb()[0]/255.00)
|
||||||
green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
|
green = float(inkex.Color(str(value.group())).to_rgb()[1]/255.00)
|
||||||
blue = float(simplestyle.parseColor(str(value.group()))[2]/255.00)
|
blue = float(inkex.Color(str(value.group())).to_rgb()[2]/255.00)
|
||||||
return simplestyle.formatColor3f(float(1.00 - calculateCMYK(red, green, blue)[0]), float(1.00), float(1.00))
|
return str(inkex.Color((float(1.00 - calculateCMYK(red, green, blue)[0]), float(1.00), float(1.00))))
|
||||||
|
|
||||||
def representM(value):
|
def representM(value):
|
||||||
# returns CMS color if available
|
# returns CMS color if available
|
||||||
if ( re.search("icc-color", value.group()) ):
|
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:
|
else:
|
||||||
red = float(simplestyle.parseColor(str(value.group()))[0]/255.00)
|
red = float(inkex.Color(str(value.group())).to_rgb()[0]/255.00)
|
||||||
green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
|
green = float(inkex.Color(str(value.group())).to_rgb()[1]/255.00)
|
||||||
blue = float(simplestyle.parseColor(str(value.group()))[2]/255.00)
|
blue = float(inkex.Color(str(value.group())).to_rgb()[2]/255.00)
|
||||||
return simplestyle.formatColor3f(float(1.00), float(1.00 - calculateCMYK(red, green, blue)[1]), float(1.00))
|
return str(inkex.Color((float(1.00), float(1.00 - calculateCMYK(red, green, blue)[1]), float(1.00))))
|
||||||
|
|
||||||
def representY(value):
|
def representY(value):
|
||||||
# returns CMS color if available
|
# returns CMS color if available
|
||||||
if (re.search("icc-color", value.group()) ):
|
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:
|
else:
|
||||||
red = float(simplestyle.parseColor(str(value.group()))[0]/255.00)
|
red = float(inkex.Color(str(value.group())).to_rgb()[0]/255.00)
|
||||||
green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
|
green = float(inkex.Color(str(value.group())).to_rgb()[1]/255.00)
|
||||||
blue = float(simplestyle.parseColor(str(value.group()))[2]/255.00)
|
blue = float(inkex.Color(str(value.group())).to_rgb()[2]/255.00)
|
||||||
return simplestyle.formatColor3f(float(1.00), float(1.00), float(1.00 - calculateCMYK(red, green, blue)[2]))
|
return str(inkex.Color((float(1.00), float(1.00), float(1.00 - calculateCMYK(red, green, blue)[2]))))
|
||||||
|
|
||||||
def representK(value):
|
def representK(value):
|
||||||
# returns CMS color if available
|
# returns CMS color if available
|
||||||
if (re.search("icc-color", value.group()) ):
|
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:
|
else:
|
||||||
red = float(simplestyle.parseColor(str(value.group()))[0]/255.00)
|
red = float(inkex.Color(str(value.group())).to_rgb()[0]/255.00)
|
||||||
green = float(simplestyle.parseColor(str(value.group()))[1]/255.00)
|
green = float(inkex.Color(str(value.group())).to_rgb()[1]/255.00)
|
||||||
blue = float(simplestyle.parseColor(str(value.group()))[2]/255.00)
|
blue = float(inkex.Color(str(value.group())).to_rgb()[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]))
|
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):
|
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:
|
if alpha:
|
||||||
alpha_command = ""
|
alpha_command = ""
|
||||||
else:
|
else:
|
||||||
alpha_command = " --export-background=white "
|
alpha_command = ";export-background:white"
|
||||||
string_inkscape_exec = ''
|
|
||||||
for color in ['C', 'M', 'Y', 'K']:
|
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"
|
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))
|
||||||
|
|
||||||
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'))
|
|
Reference in New Issue
Block a user