josa42 / atom-svg-preview

Live SVG preview for Atom editor
MIT License
51 stars 14 forks source link

unable to export as PNG or JPEG image #67

Open saikrishna-chunchu opened 3 years ago

saikrishna-chunchu commented 3 years ago

When I try to export the SVG as a PNG or JPEG image, I am seeing the below error. This is happening before I chose the destination file/directory to export the file.

OS: macOS Catalina, version: 10.15.6 (19G2021)

TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type object at Object.openSync (fs.js:439:10) at Object.func (electron/js2c/asar.js:138:31) at Object.func [as openSync] (electron/js2c/asar.js:138:31) at Object.writeFileSync (fs.js:1206:35) at /Users/schunchu/.atom/packages/svg-preview/lib/svg-preview-view.js:396:12 at HTMLImageElement. (/Users/schunchu/.atom/packages/svg-preview/lib/svg-to-raster.js:23:12)

sverweij commented 3 years ago

This means that line 392 with something like this should theoretically fix this issue:

    const dialogOutput = await atom.applicationDelegate.showSaveDialog(`${filePath}.${outputType}`)
    const outputFilePath = dialogOutput.filePath

From my experience with atom adapting the unit test could be a bit of work, but as the exportTo method is already async (for other reasons) it might to prove to be 0 minutes as well.

(don't have the bandwidth to make a PR for this a.t.m. And even if I did - not sure @josa42 would be willing and/ or able to merge it given the project not maintained label in the README)

saikrishna-chunchu commented 3 years ago

Thanks, @sverweij. I made those changes in my machine and used it, it worked. @josa42, let me if you can merge these changes. I can make PR (for the rest of community).

josa42 commented 3 years ago

@saikrishna-chunchu If you open a PR I will merge it.