gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.62k stars 7.52k forks source link

Add image.Trace method that produces an SVG #6253

Open bep opened 5 years ago

bep commented 5 years ago

In the series "bep gets totally distracted", I'm about to add a image.Trace method.

There are several examples of this work in progress here:

https://temp.bep.is/hugotest/section1/trace/

A quick note: Some of the more detailed traces have bigger file sizes than their source, but they compress great (the gzipped version is < 40%) and of course scales better when you go bigger ...

There will be default options and options in config.toml. With the full set of options the usage will be something like this:

{{ $opts := dict "filter" "previtt" "color" "orange" "low" 30 "high" 100 "turdSize" 50 }}
{{ $traced := $img.Trace $opts }} // => SVG resource

I think the default filter will be luma (brightness), which is also the fastest.

/cc @regisphilibert and gang

regisphilibert commented 5 years ago

Looks great! Don't have a concrete use case on my mind but designers must already do!

In the series "bep gets totally distracted".

Distraction is good, building pages from data source is great. 😛

divinerites commented 5 years ago

Régis my use case will be some lazy loading for my s**tload photos with small small svg but better looking than the flat grey I use for now.

Great feature bep. Thanks

bep commented 5 years ago

There are several use cases. Maybe someone wants to create a "monochrome blog", where they can possibly also get away with "wget randomcopyrightedimage.jpg" ...

andrewd72 commented 1 year ago

This would be a really nice option to have.

bep commented 1 year ago

@andrewd72 I do agree ... but I remember doing some investigations about this and wasn't impressed about the result of the library I looked at -- and it was very slow.

andrewd72 commented 1 year ago

I guess if the result isn't visually interesting, may as well go with a blur up.

bep commented 1 year ago

I guess if the result isn't visually interesting, may as well go with a blur up.

Yea, but there are millions of Go coders out there, and suddenly some very cool new SVG library may pop up.