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

Seems Imagemagick didn't handle SVG well as expected. #13

Open
suliveevil opened this issue Nov 28, 2022 · 9 comments
Open

Seems Imagemagick didn't handle SVG well as expected. #13

suliveevil opened this issue Nov 28, 2022 · 9 comments
Labels
bug Something isn't working
Milestone

Comments

@suliveevil
Copy link

截屏2022-11-28 10 23 40

@andorsk
Copy link
Owner

andorsk commented Nov 28, 2022

Thanks @suliveevil. will get back to you on this. As some level this is blocked by #8 from my end. It would be great if eventually d2 supports pngs. SVG's just don't play as well with emacs. I think I can get it to work, but I need to fix #8 first

@andorsk andorsk added the bug Something isn't working label Nov 28, 2022
@andorsk
Copy link
Owner

andorsk commented Nov 28, 2022

confirmed repeatability
image
Browser renders correctly:
image

@andorsk
Copy link
Owner

andorsk commented Nov 28, 2022

This a more general issue with imagemagik and svgs convert input.svg output.png reproduces the issue.

@andorsk
Copy link
Owner

andorsk commented Nov 28, 2022

The way I see it, there are two fixes:

  1. See if there's a fix for imagemagick and svgs.
  2. See if convert to png first with some other command, then just read that. I'm leaning toward that.

@suliveevil
Copy link
Author

Or we may should find another tool to convert svg to png?

@andorsk
Copy link
Owner

andorsk commented Nov 28, 2022

yea...possible. i'll need to look into it and get back on this.

@andorsk andorsk added this to the Alpha-0.1 milestone Nov 28, 2022
@andorsk
Copy link
Owner

andorsk commented Nov 29, 2022

referencing here #8

@andorsk
Copy link
Owner

andorsk commented Nov 29, 2022

since this is an emacs related issue, I don't see an easy way around this without saying "upgrade your emacs", however I have added support for a complementing method at #19 , which allows you to open up the browser directly from emacs through the new supported commands:

(defvar d2-mode-map
  (let ((map (make-sparse-keymap)))
    (define-key map (kbd "C-c C-c") 'd2-compile)
    (define-key map (kbd "C-c C-f") 'd2-compile-file)
    (define-key map (kbd "C-c C-b") 'd2-compile-buffer)
    (define-key map (kbd "C-c C-r") 'd2-compile-region)
    (define-key map (kbd "C-c C-h") 'd2-compile-file-and-browse)
    (define-key map (kbd "C-c C-j") 'd2-compile-buffer-and-browse)
    (define-key map (kbd "C-c C-k") 'd2-compile-region-and-browse)
    (define-key map (kbd "C-c C-o") 'd2-open-browser)
    (define-key map (kbd "C-x C-o") 'd2-view-current-svg)
    (define-key map (kbd "C-c C-d") 'd2-open-doc)
    map))

This allows the browser to render the svg, which should work pretty well.

@alixander
Copy link

alixander commented Dec 8, 2022

d2 is able to convert to png, e.g. d2 input.d2 out.png. i'm not 100% sure it would work in this context though, as it involves using headless browsers.

we also ran into some subpar svg rendering when building the Obsidian integration. we got around this by base64 encoding the SVGs. didn't end up going with that in the end, but it did work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants