more fixes in output pro

This commit is contained in:
Mario Voigt 2021-05-02 23:07:43 +02:00
parent 66757bb730
commit 8b73e65657
4 changed files with 64 additions and 28 deletions

View File

@ -1,4 +1,10 @@
eclipse.preferences.version=1
encoding//extensions/fablabchemnitz/color_harmony/color_harmony.py=utf-8
encoding//extensions/fablabchemnitz/create_links.py=utf-8
encoding//extensions/fablabchemnitz/jitter_gradients.py=utf-8
encoding//extensions/fablabchemnitz/next_gen.py=utf-8
encoding//extensions/fablabchemnitz/openClosedPath.py=utf-8
encoding//extensions/fablabchemnitz/output_pro/outputpro.py=utf-8
encoding//extensions/fablabchemnitz/path_number_subpaths.py=utf-8
encoding//extensions/fablabchemnitz/reverse_order_subpaths.py=utf-8
encoding//extensions/fablabchemnitz/svgo-inkscape/svgo.inkscape.py=utf-8

View File

@ -609,7 +609,17 @@ class OutputProBitmap(inkex.EffectExtension):
os.system('convert "' + os.path.join(dirpathTempFolder.name, 'original.png') + '" -filter box -resize 300x300 "' + os.path.join(dirpathTempFolder.name, 'original.png') + '"' )
os.system('convert "' + os.path.join(dirpathTempFolder.name, 'result.png') + '" -filter box -resize 300x300 "' + os.path.join(dirpathTempFolder.name, 'result.png') + '"' )
os.system('convert "' + os.path.join(dirpathTempFolder.name, 'original.png') + '" "' + os.path.join(dirpathTempFolder.name, 'result.png') + '" "' + os.path.join(dirpathTempFolder.name, 'preview_mask.png') + '" -composite "' + os.path.join(dirpathTempFolder.name, 'preview.png') + '"' )
os.system(
'convert "' +
os.path.join(dirpathTempFolder.name, 'original.png') +
'" "' +
os.path.join(dirpathTempFolder.name, 'result.png') +
'" "' +
os.path.join(dirpathSoftware, 'preview_mask.png') + #static file from extension directory
'" -composite "' +
os.path.join(dirpathTempFolder.name, 'preview.png') +
'"'
)
self.view_image_info.setText(file_info_final + '<br><small>' + list_of_format_tips[list_of_export_formats[self.format_choice.currentIndex()]] + '</small>')
@ -708,7 +718,16 @@ class OutputProBitmap(inkex.EffectExtension):
last_height = 0
if self.prepress_paper_cutmarks_check.isChecked():
cutmarks.generate_final_file(False, self.prepress_paper_cutmarks_inside_check.isChecked(),list_of_color_modes_jpeg[self.color_mode_choice_jpeg.currentIndex()], image_width, image_height, imposition_space,unittouu(str(self.prepress_paper_cutmarks_strokewidth_value.text()) + str(self.prepress_paper_cutmarks_strokewidth_choice.currentText())), bleedsize, marksize, dirpathTempFolder)
cutmarks.generate_final_file(False,
self.prepress_paper_cutmarks_inside_check.isChecked(),
list_of_color_modes_jpeg[self.color_mode_choice_jpeg.currentIndex()],
image_width,
image_height,
imposition_space,
unittouu(str(self.prepress_paper_cutmarks_strokewidth_value.text()) + str(self.prepress_paper_cutmarks_strokewidth_choice.currentText())),
bleedsize,
marksize,
dirpathTempFolder.name)
cut_marks_command = ['composite']
cut_marks_command.append('-compose')
@ -833,23 +852,30 @@ class OutputProBitmap(inkex.EffectExtension):
def cmyk_overprint_black(self):
if self.cmyk_overblack_jpeg.isChecked():
cmyk.generate_svg_separations(dirpathTempFolder + '/', open(os.path.join(dirpathTempFolder.name, 'original.svg')).read(), True)
cmyk.generate_svg_separations(dirpathTempFolder.name, open(os.path.join(dirpathTempFolder.name, 'original.svg')).read(), True)
else:
cmyk.generate_svg_separations(dirpathTempFolder + '/', open(os.path.join(dirpathTempFolder.name, 'original.svg')).read(), False)
cmyk.generate_svg_separations(dirpathTempFolder.name, open(os.path.join(dirpathTempFolder.name, 'original.svg')).read(), False)
def cmyk_advanced_manipulation(self):
area_to_export = self.area_to_export()
cmyk.generate_png_separations(dirpathTempFolder + '/', 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']:
subprocess.Popen(['convert', os.path.join(dirpathTempFolder.name, 'separated') + area_to_export.replace(' ', '') + color + ".png", '-colorspace', 'CMYK', '-channel', color, '-separate', dirpathTempFolder + '/' + "separated" + area_to_export.replace(' ', '') + color + ".png"]).wait()
subprocess.Popen(
['convert',
os.path.join(dirpathTempFolder.name, 'separated' + area_to_export.replace(' ', '') + color + ".png"),
'-colorspace', 'CMYK', '-channel',
color,
'-separate',
os.path.join(dirpathTempFolder.name, 'separated' + area_to_export.replace(' ', '') + color + ".png")]
).wait()
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', dirpathTempFolder + '/source.png'], stdout=subprocess.PIPE).communicate()[0]
file_info = subprocess.Popen(['identify', os.path.join(dirpathTempFolder.name, 'source.svg')], stdout=subprocess.PIPE).communicate()[0].decode('UTF-8')
image_size = file_info.split(' ')[2]
@ -1000,16 +1026,16 @@ class OutputProBitmap(inkex.EffectExtension):
self.export_button.setGeometry(430, 560, 200, 30)
self.format_preview_check.setGeometry(230, 85, 200, 25)
self.move((QtGui.QDesktopWidget().screenGeometry().width()-self.geometry().width())/2, (QtGui.QDesktopWidget().screenGeometry().height()-self.geometry().height())/2)
self.move(int((QtWidgets.QDesktopWidget().screenGeometry().width()-self.geometry().width())/2), int((QtWidgets.QDesktopWidget().screenGeometry().height()-self.geometry().height())/2))
def export(self):
self.location_path = QtGui.QFileDialog.getSaveFileName(self, _(u"Save image"), os.environ.get('HOME', None), list_of_export_formats[self.format_choice.currentIndex()]).toUtf8()
self.location_path = QtWidgets.QFileDialog.getSaveFileName(self, _(u"Save image"), os.environ.get('HOME', None), list_of_export_formats[self.format_choice.currentIndex()], options=QtWidgets.QFileDialog.DontConfirmOverwrite)
if not self.format_preview_check.isChecked():
self.generate_final_file()
if not str(self.location_path) == '':
shutil.copy2(os.path.join(dirpathTempFolder.name, 'result-imp.') + list_of_export_formats[self.format_choice.currentIndex()].lower(), self.location_path)
shutil.copy2(os.path.join(dirpathTempFolder.name, 'result-imp.' + list_of_export_formats[self.format_choice.currentIndex()].lower()), self.location_path[0] + "." + self.location_path[1].lower())

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import re, subprocess, simplestyle, os
import inkex
def calculateCMYK(red, green, blue):
C = float()
@ -87,14 +88,18 @@ def representK(value):
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(r"#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representK, svg_ready))
with open(os.path.join(temp_dir, "separationK.svg"), "w") as f:
f.write(re.sub(r"#[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(r"#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representC, svg_ready))
open(temp_dir + "separationM.svg","w").write(re.sub(r"#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representM, svg_ready))
open(temp_dir + "separationY.svg","w").write(re.sub(r"#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representY, svg_ready))
with open(os.path.join(temp_dir, "separationC.svg"), "w") as f:
f.write(re.sub(r"#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representC, svg_ready))
with open(os.path.join(temp_dir, "separationM.svg"), "w") as f:
f.write(re.sub(r"#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representM, svg_ready))
with open(os.path.join(temp_dir, "separationY.svg"), "w") as f:
f.write(re.sub(r"#[a-fA-F0-9]{6}( icc-color\(.*?\))?", representY, svg_ready))
def generate_png_separations(temp_dir, area_to_export, resolution, alpha):
if alpha:
@ -105,7 +110,8 @@ def generate_png_separations(temp_dir, area_to_export, resolution, alpha):
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/test.txt', 'w').write(string_inkscape_exec)
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)
inkscape_exec.communicate(input=string_inkscape_exec.encode('UTF-8'))

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
import subprocess
import subprocess, os
def generate_final_file(isvector, hide_inside_marks, colormode, width, height, space, strokewidth, bleedsize, marksize, temp_dir):
if not isvector:
@ -27,8 +27,8 @@ def generate_final_file(isvector, hide_inside_marks, colormode, width, height, s
number_of_line = 1
for line in height:
open('/tmp/str.txt', 'a').write(str(width.index(column)))
with open(os.path.join(temp_dir, 'str.txt'), 'a') as f:
f.write(str(width.index(column)))
if not hide_inside_marks or (hide_inside_marks and number_of_column == 1):
command.append('-draw')
@ -58,24 +58,22 @@ def generate_final_file(isvector, hide_inside_marks, colormode, width, height, s
number_of_line += 1
width_value += column + space
number_of_column += 1
command.append(temp_dir + '/cut_mark_' + color + '.png')
command.append(os.path.join(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(os.path.join(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')
command.append(os.path.join(temp_dir, 'cut_mark_' + color + '.png'))
subprocess.Popen(command).wait()
del command[:]
final_command.append(temp_dir + '/cut_mark_' + color + '.png')
final_command.append(os.path.join(temp_dir, 'cut_mark_' + color + '.png'))
final_command.extend(['-set', 'colorspace', colormode, '-combine', temp_dir + '/cut_mark.tiff'])
final_command.extend(['-set', 'colorspace', colormode, '-combine', os.path.join(temp_dir, 'cut_mark.tiff')])
subprocess.Popen(final_command).wait()