Skip to content

Commit b96d90e

Browse files
committed
[Navigate Results, PCB Print, PcbDraw][Added] Support for big SVGs
Workaround for security limitations found in rsvg-convert Closes #851
1 parent efa5461 commit b96d90e

File tree

9 files changed

+52
-21
lines changed

9 files changed

+52
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- PCB2Blender_Tools: Experimental v2.17 file generation
1818
- Report: separated N/PTH slot sizes (#824)
1919
- VRML: workaround for KiCad 9 randomly failing to copy 3D models (#804)
20+
- Navigate Results, PCB Print, PcbDraw: Support for big SVGs (#851)
2021

2122
### Fixed
2223
- User.N layer numbering. I.e. pcb_print issues with their numbering (#808)

docs/source/Changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Added
3737
- Report: separated N/PTH slot sizes (#824)
3838
- VRML: workaround for KiCad 9 randomly failing to copy 3D models
3939
(#804)
40+
- Navigate Results, PCB Print, PcbDraw: Support for big SVGs (#851)
4041

4142
Fixed
4243
~~~~~

docs/source/dependencies.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@
8989
- Find commit hash and/or date for `sch_replace`
9090
- Find commit hash and/or date for `set_text_variables`
9191

92-
`RSVG tools <https://gitlab.gnome.org/GNOME/librsvg>`__ :index:`: <pair: dependency; RSVG tools>` |image37| |image38| |Auto-download|
92+
`RSVG tools <https://gitlab.gnome.org/GNOME/librsvg>`__ :index:`: <pair: dependency; RSVG tools>` v2.40.3 |image37| |image38| |Auto-download|
9393

9494
- Optional to:
9595

96-
- SVG logos for the BoM for `bom`
97-
- Create outputs preview for `navigate_results`
98-
- Create PNG icons for `navigate_results`
99-
- Create outputs preview for `navigate_results_rb`
100-
- Create PNG icons for `navigate_results_rb`
101-
- Create PDF, PNG, PS and EPS formats for `pcb_print`
102-
- Create PNG, JPG and BMP images for `pcbdraw`
96+
- SVG logos for the BoM for `bom` (v2.40.3)
97+
- Create outputs preview for `navigate_results` (v2.40.3)
98+
- Create PNG icons for `navigate_results` (v2.40.3)
99+
- Create outputs preview for `navigate_results_rb` (v2.40.3)
100+
- Create PNG icons for `navigate_results_rb` (v2.40.3)
101+
- Create PDF, PNG, PS and EPS formats for `pcb_print` (v2.40.3)
102+
- Create PNG, JPG and BMP images for `pcbdraw` (v2.40.3)
103103

104104
`ImageMagick <https://imagemagick.org/>`__ :index:`: <pair: dependency; ImageMagick>` |image39| |image40| |Auto-download|
105105

kibot/dep_downloader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
arch: librsvg
4141
command: rsvg-convert
4242
downloader: rsvg
43+
version: 2.40.3
4344
id: RSVG
4445
tests:
4546
- command: [convert, -list, font]

kibot/out_any_navigate_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def add_to_tree(self, cat, out, o_tree):
204204
node[out.name] = out
205205

206206
def svg_to_png(self, svg_file, png_file, width):
207-
cmd = [self.rsvg_command, '-w', str(width), '-f', 'png', '-o', png_file, svg_file]
207+
cmd = [self.rsvg_command, '-w', str(width), '-f', 'png', '--unlimited', '-o', png_file, svg_file]
208208
return _run_command(cmd)
209209

210210
def copy(self, img, width):

kibot/out_pcb_print.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,8 +1299,8 @@ def svg_to_pdf(self, input_folder, svg_file, pdf_file):
12991299
# We use a 5x scale and then reduce it to maintain the page size
13001300
# Note: rsvg 2.50.3 has this problem 2.54.5 doesn't, so we ensure the size is correct, not a fixed scale
13011301
dpi = str(self.dpi)
1302-
cmd = [self.rsvg_command, '-d', dpi, '-p', dpi, '-f', 'pdf', '-o', os.path.join(input_folder, pdf_file),
1303-
os.path.join(input_folder, svg_file)]
1302+
cmd = [self.rsvg_command, '-d', dpi, '-p', dpi, '-f', 'pdf', '--unlimited', '-o',
1303+
os.path.join(input_folder, pdf_file), os.path.join(input_folder, svg_file)]
13041304
_run_command(cmd)
13051305

13061306
# We can't control the resolution in this way

kibot/out_pcbdraw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def create_image(self, name, board):
486486
if self.rsvg_command:
487487
logger.debug('Converting {} -> {}'.format(svg_save_output_name, save_output_name))
488488
cmd = [self.rsvg_command, '--dpi-x', str(self.dpi), '--dpi-y', str(self.dpi),
489-
'--output', save_output_name, '--format', 'png', svg_save_output_name]
489+
'--output', save_output_name, '--format', 'png', '--unlimited', svg_save_output_name]
490490
_run_command(cmd)
491491
os.remove(svg_save_output_name)
492492
# Do we need to convert the saved file? (JPG/BMP)

src/kibot-check

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,55 +1211,83 @@ deps = '{\
12111211
"mandatory": false,\
12121212
"max_version": null,\
12131213
"output": "bom",\
1214-
"version": null\
1214+
"version": [\
1215+
2,\
1216+
40,\
1217+
3\
1218+
]\
12151219
},\
12161220
{\
12171221
"all_versions": {},\
12181222
"desc": "Create outputs preview",\
12191223
"mandatory": false,\
12201224
"max_version": null,\
12211225
"output": "navigate_results",\
1222-
"version": null\
1226+
"version": [\
1227+
2,\
1228+
40,\
1229+
3\
1230+
]\
12231231
},\
12241232
{\
12251233
"all_versions": {},\
12261234
"desc": "Create PNG icons",\
12271235
"mandatory": false,\
12281236
"max_version": null,\
12291237
"output": "navigate_results",\
1230-
"version": null\
1238+
"version": [\
1239+
2,\
1240+
40,\
1241+
3\
1242+
]\
12311243
},\
12321244
{\
12331245
"all_versions": {},\
12341246
"desc": "Create outputs preview",\
12351247
"mandatory": false,\
12361248
"max_version": null,\
12371249
"output": "navigate_results_rb",\
1238-
"version": null\
1250+
"version": [\
1251+
2,\
1252+
40,\
1253+
3\
1254+
]\
12391255
},\
12401256
{\
12411257
"all_versions": {},\
12421258
"desc": "Create PNG icons",\
12431259
"mandatory": false,\
12441260
"max_version": null,\
12451261
"output": "navigate_results_rb",\
1246-
"version": null\
1262+
"version": [\
1263+
2,\
1264+
40,\
1265+
3\
1266+
]\
12471267
},\
12481268
{\
12491269
"all_versions": {},\
12501270
"desc": "Create PDF, PNG, PS and EPS formats",\
12511271
"mandatory": false,\
12521272
"max_version": null,\
12531273
"output": "pcb_print",\
1254-
"version": null\
1274+
"version": [\
1275+
2,\
1276+
40,\
1277+
3\
1278+
]\
12551279
},\
12561280
{\
12571281
"all_versions": {},\
12581282
"desc": "Create PNG, JPG and BMP images",\
12591283
"mandatory": false,\
12601284
"max_version": null,\
12611285
"output": "pcbdraw",\
1262-
"version": null\
1286+
"version": [\
1287+
2,\
1288+
40,\
1289+
3\
1290+
]\
12631291
}\
12641292
],\
12651293
"tests": [\

tests/utils/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,15 +573,15 @@ def compare_image(self, image, reference=None, diff='diff.png', ref_out_dir=Fals
573573
png_ref = None
574574
if reference[-3:] == 'svg':
575575
png_ref = reference[:-3]+'png'
576-
cmd = ['rsvg-convert', '-b', '#FFFFFF', '-h', '2160', '-o', png_ref, reference]
576+
cmd = ['rsvg-convert', '-b', '#FFFFFF', '-h', '2160', '--unlimited', '-o', png_ref, reference]
577577
logging.debug('Converting reference to PNG with: '+usable_cmd(cmd))
578578
subprocess.check_call(cmd)
579579
reference = png_ref
580580
assert os.path.isfile(png_ref)
581581
png_image = None
582582
if image[-3:] == 'svg':
583583
png_image = image[:-3]+'png'
584-
cmd = ['rsvg-convert', '-b', '#FFFFFF', '-h', '2160', '-o', png_image, image]
584+
cmd = ['rsvg-convert', '-b', '#FFFFFF', '-h', '2160', '--unlimited', '-o', png_image, image]
585585
logging.debug('Converting result image to PNG with: '+usable_cmd(cmd))
586586
subprocess.check_call(cmd)
587587
image = png_image

0 commit comments

Comments
 (0)