Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with pixel dimensions #4

Open
yul opened this issue Mar 16, 2020 · 1 comment
Open

Not working with pixel dimensions #4

yul opened this issue Mar 16, 2020 · 1 comment

Comments

@yul
Copy link

yul commented Mar 16, 2020

Hello, thanks for sharing this project. I am trying to use this lib for my project, and while micro service version works correct, this lib does not work for the same SVG.
SVG in question is this:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="5595" height="5842" viewBox="0 0 5595 5842">
<path d="M 10.423511 5.6126619 H 145.39461"
      style="stroke: rgb(204,204,0); stroke-width: 5; stroke-dasharray: none; stroke-linecap: round; stroke-linejoin: miter; stroke-miterlimit: 4; fill: none; fill-rule: nonzero; opacity: 1;"
      transform="translate(1460.24 1311.29) scale(3.78 3.78) translate(-77.90906050000001, -5.6126619) "
      stroke-linecap="round"/>
<ellipse cx="0" cy="0" rx="16.5" ry="16.5"
         style="stroke: rgb(204,204,0); stroke-width: 5; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: none; fill-rule: nonzero; opacity: 1;"
         transform="translate(419.37 165.71) rotate(90)"/>
<line x1="0" y1="-37.5" x2="0" y2="37.5"
      style="stroke: rgb(204,204,0); stroke-width: 5; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;"
      transform="translate(119.5 362.11) scale(1 0.99)"/>
<line x1="0" y1="-37.5" x2="0" y2="37.5"
      style="stroke: rgb(204,204,0); stroke-width: 5; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;"
      transform="translate(447 361.61) scale(1 0.99)"/>
<line x1="0" y1="-37.5" x2="0" y2="37.5"
      style="stroke: rgb(204,204,0); stroke-width: 5; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;"
      transform="translate(282.99 399.6) rotate(90.07) scale(1 4.42)"/>
</svg>

The source of problems is the first line with dimensions in pixels. When dimensions are in mm, it works, but it converts them to pixels somehow.

Most recent version of the lib returns this error:

Error: w and h must be numbers
at Jimp.throwError (/var/www/svgconvert/node_modules/@jimp/utils/dist/index.js:26:13)
at Jimp.scanQuiet (/var/www/svgconvert/node_modules/@jimp/core/dist/index.js:1301:30)
at Jimp.(anonymous function) [as scan] (/var/www/svgconvert/node_modules/@jimp/core/dist/index.js:1222:23)
at Potrace._processLoadedImage (/var/www/svgconvert/node_modules/potrace/lib/Potrace.js:1003:11)
at Jimp.<anonymous> (/var/www/svgconvert/node_modules/potrace/lib/Potrace.js:1046:14)
at Timeout._onTimeout (/var/www/svgconvert/node_modules/@jimp/core/dist/index.js:331:25)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)

I have tried this:

to install the same libraries versions (not sure if I did all correct, though)

result is just a bit different

TypeError: Cannot read property 'bitmap' of undefined
at Potrace._processLoadedImage (/var/www/svgconvert/node_modules/potrace/lib/Potrace.js:1000:35)
at Jimp.<anonymous> (/var/www/svgconvert/node_modules/potrace/lib/Potrace.js:1046:14)
at Jimp.throwError (/var/www/svgconvert/node_modules/potrace/node_modules/jimp/index.js:85:44)
at /var/www/svgconvert/node_modules/potrace/node_modules/jimp/index.js:298:44
at exports.PNG.<anonymous> (/var/www/svgconvert/node_modules/pngjs/lib/png.js:81:7)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at exports.PNG.emit (events.js:211:7)
at emitOne (events.js:116:13)
at module.exports.emit (events.js:211:7)

at the same time microservice at https://micro-outline-stroke.now.sh/ returns result correctly.

I'm not sure where to search for the problem, can you give me any advice on this?

@elrumordelaluz
Copy link
Owner

elrumordelaluz commented Apr 29, 2021

@yul sorry for the late reply, trying your code here https://outline-stroke.vercel.app/ I am getting this result:

<svg xmlns="http://www.w3.org/2000/svg" width="5595" height="5842" viewBox="0 0 5595 5842" version="1.1">
  <path d="M 412 148.121 C 405.472 150.716, 400.738 157.969, 400.674 165.474 C 400.531 182.027, 419.240 190.630, 431.662 179.724 C 436.089 175.837, 438 171.545, 438 165.492 C 438 154.981, 429.825 146.924, 419.300 147.063 C 416.660 147.098, 413.375 147.574, 412 148.121 M 412.304 153.956 C 407.862 156.665, 405.666 160.431, 405.672 165.329 C 405.680 171.547, 408.340 175.821, 413.673 178.180 C 419.472 180.745, 423.956 179.984, 428.709 175.628 C 435.229 169.652, 434.199 158.531, 426.701 153.960 C 422.608 151.463, 416.395 151.462, 412.304 153.956 M 444.709 324.624 C 444.319 325.014, 444 341.458, 444 361.167 L 444 397 283 397 L 122 397 122 361 L 122 325 119.500 325 L 117 325 117 363.500 L 117 402 282.939 402 L 448.877 402 449.483 397.750 C 449.816 395.413, 449.956 377.975, 449.794 359 C 449.505 325.141, 449.462 324.495, 447.459 324.208 C 446.336 324.047, 445.099 324.235, 444.709 324.624 M 1198.923 1304.923 C 1194 1309.846, 1195.384 1317.268, 1201.710 1319.873 C 1203.792 1320.731, 1269.780 1320.956, 1461.832 1320.761 L 1719.164 1320.500 1722.082 1317.234 C 1723.687 1315.438, 1725 1313.053, 1725 1311.935 C 1725 1309.057, 1722.329 1304.246, 1720.055 1303.030 C 1718.750 1302.331, 1635.126 1302, 1459.989 1302 L 1201.846 1302 1198.923 1304.923" stroke="none" fill="inherit" fill-rule="evenodd"/>
</svg>

Please let me know if this is correct or not.
Thank you,

update after read more detailed

Will investigate directly with the lib instead. Will come back to you asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants