Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/h2non/go-is-svg
Check if a given buffer is a valid SVG image in Go (golang)
https://github.com/h2non/go-is-svg
svg
Last synced: about 1 month ago
JSON representation
Check if a given buffer is a valid SVG image in Go (golang)
- Host: GitHub
- URL: https://github.com/h2non/go-is-svg
- Owner: h2non
- License: mit
- Created: 2016-09-27T20:47:55.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-27T21:24:56.000Z (about 8 years ago)
- Last Synced: 2024-10-18T11:25:44.733Z (about 2 months ago)
- Topics: svg
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome - go-is-svg - Check if it is an SVG image (Open source library / Graphics Processing)
README
# go-is-svg [![Build Status](https://travis-ci.org/h2non/go-is-svg.png)](https://travis-ci.org/h2non/go-is-svg) [![GoDoc](https://godoc.org/github.com/h2non/go-is-svg?status.svg)](https://godoc.org/github.com/h2non/go-is-svg) [![Coverage Status](https://coveralls.io/repos/github/h2non/go-is-svg/badge.svg?branch=master)](https://coveralls.io/github/h2non/go-is-svg?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/h2non/go-is-svg)](https://goreportcard.com/report/github.com/h2non/go-is-svg)
Tiny package to verify if a given file buffer is an SVG image in Go (golang).
See also [filetype](https://github.com/h2non/filetype) package for binary files type inference.
## Installation
```bash
go get -u github.com/h2non/go-is-svg
```## Example
```go
package mainimport (
"fmt"
"io/ioutil"svg "github.com/h2non/go-is-svg"
)func main() {
buf, err := ioutil.ReadFile("_example/example.svg")
if err != nil {
fmt.Printf("Error: %s\n", err)
return
}if svg.Is(buf) {
fmt.Println("File is an SVG")
} else {
fmt.Println("File is NOT an SVG")
}
}
```Run example:
```bash
go run _example/example.go
```## License
MIT - Tomas Aparicio