Add a component image generator - #1435
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1435 +/- ##
============================================
+ Coverage 59.77% 60.30% +0.53%
- Complexity 9103 9334 +231
============================================
Files 679 681 +2
Lines 29618 30181 +563
============================================
+ Hits 17703 18200 +497
- Misses 11915 11981 +66 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
27e99c8 to
9ebf399
Compare
af9c923 to
0ec45ac
Compare
|
Im not sure if i find the term "Value calculator" so fitting for it. |
|
You're right that "Value calculator" mis-describes it — thanks for flagging. It actually does two related things, and the name should make that clearer:
So a "codeword → value" direction does exist, but I agree the image generation is the headline and the current name hides it. Renaming options:
Do you have a preference? Happy to rename the tool, its route, permission and menu entry to match. PS — I've added screenshots to the PR description above (the calculator tabs + the bulk "generate images" review page) so the two halves are easier to see. |
|
I would say Component image generator, seems to fit the overall purpose of this tool quite well. |
…ck on PR Part-DB#1435): update the tool title + permission label; route/permission slugs stay as internal identifiers
0ec45ac to
3fd700d
Compare
d73bc42 to
1f98a9c
Compare
1f98a9c to
6dc4904
Compare
|
is this PR finished? |
|
Done — renamed to Component image generator everywhere: the tool title, the Tools-menu entry, the route ( |
Adds a "Value calculator" tool (Tools menu) that decodes/encodes the value of common components and generates a clean SVG picture you can attach to a part — handy for assortments imported with blank thumbnails and sparse data. Calculator tabs (bidirectional decode <-> encode), each drawing the part to the selected package with a collapsible appearance panel and an "attach to part" action (optionally as the master picture): - Resistor: 4/5/6-band colour code - Capacitor: value <-> 3-digit code <-> tolerance - SMD resistor: value <-> 3-digit / 4-digit / EIA-96 code - Inductor: colour-band code - SMD inductor: value <-> uH code Bulk "Generate component images" parts-table action: - Classifies each selected part (resistor / capacitor / inductor / diode / LED, THT or SMD) with ComponentValueGuesser and detects value, voltage, tolerance, power, ppm, pitch, diameter, colour, SMD package and marking from the name, description and parameters. - Renders a preview per part, lets you tweak appearance, and attaches the images in one go; can also write matching KiCad symbol/footprint/reference-prefix EDA fields. Backend: ComponentValueGuesser (classification + detection + EDA suggestion), GeneratedImageAttachmentHelper (stores the SVG through the existing attachment pipeline, so it is sanitised on save), two POST endpoints on PartController (generate_image, set_eda) guarded by `edit` + CSRF, a new `@tools.value_calculator` permission, a Tools-tree entry and docs. All drawing is client-side in a Stimulus controller; the un-sanitised live preview escapes part-derived text and validates colours as defence-in-depth. Tests: unit tests for ComponentValueGuesser and functional tests for the endpoints, including permission and CSRF enforcement and the persisted side effects.
6dc4904 to
0dac22b
Compare
|
Rebased onto the latest master. All PHPUnit jobs (PHP 8.2–8.5 × mysql/postgres/sqlite), the asset build and codecov are green. One heads-up on the red Static analysis: it isn't this PR — the Symfony security-checker step is flagging |
Component value calculator & image generator
Adds a Value calculator tool (Tools menu) that decodes/encodes the value of common components and generates a clean SVG picture you can attach to a part — handy for assortments (e.g. AliExpress kits) imported with blank thumbnails and sparse data.
Calculator tabs
Each tab is a bidirectional decoder/encoder, draws the part to the selected package with a collapsible "appearance" panel, and can attach the rendered image (optionally as the master picture):
Bulk "Generate component images" (parts-table action)
ComponentValueGuesserand detects value, voltage, tolerance, power, ppm, pitch, diameter, colour, SMD package and marking from the name, description and parameters.Implementation
ComponentValueGuesser— classification + detection + EDA suggestion.GeneratedImageAttachmentHelper— stores the SVG through the existing attachment pipeline, so every generated image is run through the SVG sanitizer on save.POSTendpoints onPartController(generate_image,set_eda) guarded byedit+ CSRF.@tools.value_calculatorpermission, a Tools-tree entry, and docs.Tests
Unit tests for
ComponentValueGuesserand functional tests for the endpoints, including permission/CSRF enforcement and the persisted side effects.Open question for review
The tool is currently called a "calculator", but roughly half its value is image generation for real parts, and some tabs are really decoders/converters. Happy to rename or restructure (e.g. "Component value & image tool", or split "Decoder" vs "Image generator") — whatever fits Part-DB best.
Screenshots






