Code Monkey home page Code Monkey logo

Comments (5)

mattsrinc avatar mattsrinc commented on June 2, 2024

Is this the part in the render.js Command function that could be changed (regex to support float numbers and changing parsing calls below to parseFloat):

https://github.com/shakiba/svgexport/blob/0cd3dab8c8fddf107b1e7a17be024f2462d30ebb/render.js#L245

UPDATE: so this change should work:

230c230
}) || params.last(/^(\d+(.\d+)?):$/i, function(match) {
232c232
output.width = parseFloat(match[1]);
234c234
}) || params.last(/^:(\d+(.\d+)?)$/i, function(match) {
236c236
output.height = parseFloat(match[1]);
238c238
}) || params.last(/^(\d+(.\d+)?):(\d+(.\d+)?)$/i, function(match) {
240,241c240,241
output.width = parseFloat(match[1]);
output.height = parseFloat(match[3]);
245c245,246
params.last(/^((-?\d+(.\d+)?):(-?\d+(.\d+)?):)?(\d+(.\d+)?):(\d+(.\d+)?)$/i, function(match) {
247,250c248,251
left : parseFloat(match[2]) || 0,
top : parseFloat(match[4]) || 0,
width : parseFloat(match[6]),
height : parseFloat(match[8])

but the command like this:
> svgexport map.svg tiles/2/2/2.png 1589.2450:2212.9800:1106.49:1106.49 256:256 "svg{background:none}"
map.svg tiles/2/2/2.png png 100% 0.23136223553760088x 1589.24:2212.98:1106.49:1106.49 256:256

exports cropped image with missing area (wrong):

Screen Shot 2021-04-06 at 19 45 29

Any clue? Map tiles get "stitched" together fine now with no shifting when zooming in but now I have a new issue (I am pretty sure all conversions took less than 30 seconds e.g. timeout that could be set).

from svgexport.

mattsrinc avatar mattsrinc commented on June 2, 2024

Any help about this?

I'm attaching my modified version of render.js that unfortunately exports images as above.

Would really love to get this solved.

render.js.zip

from svgexport.

mattsrinc avatar mattsrinc commented on June 2, 2024

For anyone doing similar task (exporting SVG to PNG tile images for Leafleat maps) here's the changed render.js for svgexport 0.3.2. It adds floating numbers support for the viewBox parameter (and width and height) and works well, with no artifacts when zooming as demonstrated in first image above.

Now if only svgexport 0.4 (or 0.5?) would have this it would be perfect.
render.js-0.3.2-floatiing-numbers-viewBox.zip

from svgexport.

yisibl avatar yisibl commented on June 2, 2024

Try https://github.com/yisibl/resvg-js

from svgexport.

mattsrinc avatar mattsrinc commented on June 2, 2024

Resvg-js looks promising (have anyone tried with similar expected results e.g. SVG viewbox with floating numbers exported to PNG with integer dimensions?).

But I've solved what's needed with modifications above, hope they'll get merged to main svgexport.code.

from svgexport.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.