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 = []
for subSplitLine in subSplitLineArray:
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])]
lineStringTransformed = [(cspTransformed[0][1][0], cspTransformed[0][1][1]), (cspTransformed[1][1][0], cspTransformed[1][1][1])]
if so.remove_trim_duplicates is True:

View File

@ -8,7 +8,6 @@ import os
import sys
import subprocess
from subprocess import Popen, PIPE
import warnings
import inkex
from inkex import Rectangle
import inkex.command
@ -17,7 +16,8 @@ import tempfile
from PIL import Image
import base64
from io import BytesIO
import warnings
warnings.simplefilter('ignore', Image.DecompressionBombWarning)
from lxml import etree
from scour.scour import scourString
@ -244,7 +244,11 @@ class ExportObject(inkex.EffectExtension):
for elem in selected.values():
elem.delete()
#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()
img.save(output_buffer, format='PNG')
byte_data = output_buffer.getvalue()