Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dthung1602/image2css
A go package that converts images to pure CSS art with thousands of box shadows
https://github.com/dthung1602/image2css
box-shadow css css-art go golang image-processing wasm web-assembly
Last synced: 28 days ago
JSON representation
A go package that converts images to pure CSS art with thousands of box shadows
- Host: GitHub
- URL: https://github.com/dthung1602/image2css
- Owner: dthung1602
- License: wtfpl
- Created: 2023-03-18T13:15:11.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-19T04:25:53.000Z (almost 2 years ago)
- Last Synced: 2024-11-09T06:20:08.980Z (3 months ago)
- Topics: box-shadow, css, css-art, go, golang, image-processing, wasm, web-assembly
- Language: Go
- Homepage: https://dthung1602.github.io/image2css
- Size: 6.95 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![WTFPL License][license-shield]][license-url]
Convert image to pure CSS art with box shadow
Try in browser
## Getting Started
Use as CLI:
```bash
make build_cli
./image2css --input path/to/image --output output/css/file
```Options:
```
-i, --input Path to input image. Only support PNG, JPG and GIF
-o, --output Path ot output CSS file. Default: path/to/input/image/image-name.css
-s, --selector CSS selector to render CSS. Default: #target
-w, --width Target image width. Default: input image width
-h, --height Target image height. Default: input image height
-r, --resolution Size (in px) of one shadow box. 1 = best resolution. Default: 5
```> Note: try to keep the number of shadows less than 10000
>
> Browser might freeze if there are more
>
> `shadows number = width * height / (resolution ** 2)`Use as WASM module:
```
make build_wasm
open docs/index.html
```Use as a Go package:
```bash
go get github.com/dthung1602/image2css
``````go
package mainimport (
"os"
"image"
image2css "github.com/dthung1602/image2css/pkg"
)func main() {
f, _ := os.Open("path/to/image.png")
img, _, _ := image.Decode(f)
img = image2css.ScaleImage(img, 300, 400) // Rescale the image if you likeresolution := 4
cssSelector := "#my-image"
css := image2css.GenCSS(img, resolution, cssSelector)
// do something with the css string
}
```## License
Distributed under the WTFPL License.
**You just DO WHAT THE F*CK YOU WANT TO**
## Contributing
Any contributions you make are greatly appreciated.
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request## Contact
Duong Thanh Hung - [[email protected]](mailto:[email protected])
Project Link: [https://github.com/dthung1602/image2css](https://github.com/dthung1602/image2css)
## Acknowledgements
* [Original PHP implementation](https://github.com/jaysalvat/image2css)
* [Black chancery font](https://www.freefontspro.com/14296/black-chancery.ttf)
* [Font awesome](https://fontawesome.com/icons)
* [Ace editor](https://ace.c9.io/)
* [Img Shields](https://shields.io)
* [Best README template](https://github.com/othneildrew/Best-README-Template)[contributors-shield]: https://img.shields.io/github/contributors/dthung1602/image2css.svg?style=flat-square
[contributors-url]: https://github.com/dthung1602/image2css/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/dthung1602/image2css.svg?style=flat-square
[forks-url]: https://github.com/dthung1602/image2css/network/members
[stars-shield]: https://img.shields.io/github/stars/dthung1602/image2css.svg?style=flat-square
[stars-url]: https://github.com/dthung1602/image2css/stargazers
[issues-shield]: https://img.shields.io/github/issues/dthung1602/image2css.svg?style=flat-square
[issues-url]: https://github.com/dthung1602/image2css/issues
[license-shield]: https://img.shields.io/github/license/dthung1602/image2css.svg?style=flat-square
[license-url]: https://github.com/dthung1602/image2css/blob/master/LICENSE