some more small fixes

This commit is contained in:
Mario Voigt 2021-07-15 16:28:01 +02:00
parent 9d00a29d83
commit e9c047d336
2 changed files with 11 additions and 4 deletions

View File

@ -1200,7 +1200,10 @@ class ContourScannerAndTrimmer(inkex.EffectExtension):
allSubSplitLineStringsTransformed = [] allSubSplitLineStringsTransformed = []
for subSplitLine in subSplitLineArray: for subSplitLine in subSplitLineArray:
csp = subSplitLine.path.to_arrays() csp = subSplitLine.path.to_arrays()
cspTransformed = Path(subSplitLine.path.transform(subSplitLine.getparent().composed_transform())).to_arrays() if subSplitLine.getparent() != None:
cspTransformed = Path(subSplitLine.path.transform(subSplitLine.getparent().composed_transform())).to_arrays()
else:
cspTransformed = csp
lineString = [(csp[0][1][0], csp[0][1][1]), (csp[1][1][0], csp[1][1][1])] lineString = [(csp[0][1][0], csp[0][1][1]), (csp[1][1][0], csp[1][1][1])]
lineStringTransformed = [(cspTransformed[0][1][0], cspTransformed[0][1][1]), (cspTransformed[1][1][0], cspTransformed[1][1][1])] lineStringTransformed = [(cspTransformed[0][1][0], cspTransformed[0][1][1]), (cspTransformed[1][1][0], cspTransformed[1][1][1])]
if so.remove_trim_duplicates is True: if so.remove_trim_duplicates is True:

View File

@ -8,7 +8,6 @@ import os
import sys import sys
import subprocess import subprocess
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import warnings
import inkex import inkex
from inkex import Rectangle from inkex import Rectangle
import inkex.command import inkex.command
@ -17,7 +16,8 @@ import tempfile
from PIL import Image from PIL import Image
import base64 import base64
from io import BytesIO from io import BytesIO
import warnings
warnings.simplefilter('ignore', Image.DecompressionBombWarning)
from lxml import etree from lxml import etree
from scour.scour import scourString from scour.scour import scourString
@ -244,7 +244,11 @@ class ExportObject(inkex.EffectExtension):
for elem in selected.values(): for elem in selected.values():
elem.delete() elem.delete()
#read png file and get base64 string from it #read png file and get base64 string from it
img = Image.open(png_export) try:
img = Image.open(png_export)
except Image.DecompressionBombError as e: #we could also increse PIL.Image.MAX_IMAGE_PIXELS = some large int
self.msg("Error. Image is too large. Reduce DPI and try again!")
exit(1)
output_buffer = BytesIO() output_buffer = BytesIO()
img.save(output_buffer, format='PNG') img.save(output_buffer, format='PNG')
byte_data = output_buffer.getvalue() byte_data = output_buffer.getvalue()