Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Image Effects with CSS (bennettfeely.com)
203 points by bennettfeely on Nov 26, 2016 | hide | past | favorite | 18 comments



Slightly related question: Does the carbon footprint increase with all this client side rendering?

I would think just rendering something charcoal on the computer of the designer should be enough, rather than repeating it on the machines of thousands of visitors?


Yes, and if your website is using CSS effects to change the same image for every user then you're making a mistake. Just render the modified image to a static asset and serve that.

However, if you want to use a pencil effect on an image that you don't have control over (eg a user's image before they upload it, or something from an API-driven service like Unsplash) then the technique still has a lot of value.


It's a good question. What about the network transmission? What's the carbon footprint of transmitting a 50k image to thousands of visitors vs a handful of bytes in css? I agree it does push more energy usage to the client, but I'm not sure how total energy usage adds up.

In any event I don't like it because it kills my battery.


Are these really that CPU intensive? It's a very basic transform. Probably a rounding error in terms of overall rendering energy usage.


Awesome resource. I've spent a lot of time looking for CSS image effects and found the info out there to be really lacking. Thanks for putting this together.


This is impressive and the documentation is nice. But it would be nice to get the 30-second pitch -- is the rationale to push processing onto the client side? When I think of such effects, I would usually imagine them being on the server side, perhaps on a dedicated image processing server.


One advantage is designers having more control to art direct content that's managed by the client (eg make all the images higher contrast and sepia). Sure it can be done on the backend - but that's more out of reach for designers than css. Css also has the advantage of being animatable.


Client side image editor is the first thing I thought of.


But how would you then download the edited image? Either browsers support taking screenshots via an API (no browser extension) or you would need to render it on the server side again. Maybe I am missing something?


You can render SVG with foreign HTML+CSS to a canvas[1]. I did that in one of my apps (guitar fretboard diagram generator) to render PNGs from my dynamic React components. Worked like a charm!

[1] https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/...


That was my first thought as well -- it is nice to push compute resources to the client side but the image just exists in memory (as opposed to a transformation process on the server side which takes image inputs and image outputs and can remotely cache the output image.) The other good thing about the server side is super-easy and super-fast pushes to social services, backups, auto-persisted change history, etc.


If it was done inside a canvas it would be possible to save it. The effects would not be as simple to create though.


I did something similar in pure JS a few years ago. It's definitely possible to render the image into a canvas and save it/upload it/present as a data uri.

I'm pretty sure the applied css effects should carry over to the canvas.

Recently, I've been looking more into WebGL and what's possible with GLSL shader scripts for image warping (for VR) and image processing/effects. see shadertoy.com etc.


It's like PhotoShop. I used to play with pictures and obtain those effects 10-15 years ago. But I think we can do many more special effects with HTML5 Canvas.


Its good to see stuff we were doing with java applets and Flash now just are part of our web frameworks. Its a weird process flow but its slowly getting there.


Nice. I consider this a hack though, I think that SVG filters are more suitable for this task.


Will gladly use, but what is the code's license?


Impressive.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: