goseq icon indicating copy to clipboard operation
goseq copied to clipboard

Add native support for generating PNG images

Open lmika opened this issue 7 years ago • 7 comments

Add an option to draw the sequence diagram as a rasterisation of PNG. This will remove the need to use ImageMagick to rasterise SVGs to PNGs.

lmika avatar Feb 20 '18 21:02 lmika

Go SVG rasteriser example here: https://stackoverflow.com/a/63227777

Alternatively, but a much bigger job, use something like https://github.com/tdewolff/canvas or https://github.com/llgcode/draw2d that can then output to many vector and raster formats.

(ahh, now I see you have a branch for draw2d, cool)

TheMightyGit avatar Oct 08 '20 10:10 TheMightyGit

Thanks for the tip regarding the SVG rasteriser, @TheMightyGit. That "draw2d" branch is quite old: I think I was trying to do too much in it with rewriting the code that actually generated the SVG diagram in an image agnostic way. It might be worth abandoning it and simply using the rasteriser, depending on how well it handles the generated SVG.

lmika avatar Oct 09 '20 10:10 lmika

Now I've thought about it for a while, maybe anything other than SVG output is overscope? There are so many great SVG conversion tools out there why complicate the goseq codebase with any rasterisation code at all?

"Do one thing well" - and a diagram tool that outputs to a common open vector standard is doing its job well.

Maybe the lack of built in output formats can be mitigated with docs and help text that explains how (and what) to use to convert from SVG into other common formats?

TheMightyGit avatar Oct 09 '20 12:10 TheMightyGit

Yeah, I know for myself I can never find a good SVG rasterising tool whenever I need it. But this issue has been open for so long and I haven't done anything to resolve it, so I'm happy to just close it with no further action.

lmika avatar Oct 09 '20 20:10 lmika

Yes, for me the PNG build flag mentioned in the README doesn't work

$ go get -tags im github.com/lmika/goseq
go: downloading github.com/lmika/goseq v0.0.1
go: downloading github.com/howeyc/fsnotify v0.9.0
go: downloading github.com/ajstarks/svgo v0.0.0-20200725142600-7a3c8b57fecb
go: downloading github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
go: downloading github.com/quirkey/magick v0.0.0-20140324185457-b37664054620
# github.com/quirkey/magick
pkg/mod/github.com/quirkey/[email protected]/magick.go:19:10: fatal error: magick/MagickCore.h: No such file or directory
   19 | #include <magick/MagickCore.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

because I don't have a MagickCore.h file, not sure where that's supposed to come from.

sionleroux avatar May 26 '21 12:05 sionleroux

But like mentioned above, it's a non-issue. E.g. if you have imagemagick installed then you can just pipe the SVG to PNG, e.g. like this

goseq <<<"Client->Server: Hello" | convert svg:- hello-seq.png

results in a hello-seq.png file that looks like this: hello-seq

sionleroux avatar May 26 '21 12:05 sionleroux

Thanks for that, @sinisterstuf. In retrospect I kind of regret adding that feature given that it pulls in/requires ImageMagick. Maybe the fix for this is simply to drop the flag.

lmika avatar May 29 '21 23:05 lmika