An open API service indexing awesome lists of open source software.

https://github.com/solovev/gopsd

PSD parser in Go
https://github.com/solovev/gopsd

golang golang-library parser photoshop psd reader

Last synced: 13 days ago
JSON representation

PSD parser in Go

Awesome Lists containing this project

README

          

## gopsd
> Photoshop document parser in Golang

### Example

```go
package main

import (
"fmt"
"image/png"
"os"

"github.com/solovev/gopsd"
)

func main() {
doc, err := gopsd.ParseFromPath("./test.psd")
checkError(err)

os.Mkdir("./images", 0777)

for _, layer := range doc.Layers {
fmt.Println(layer.ToString())

saveAsPNG(layer)
}
}

func saveAsPNG(layer *gopsd.Layer) {
out, err := os.Create("./images/" + layer.Name + ".png")
checkError(err)

img, err := layer.GetImage()
checkError(err)

err = png.Encode(out, img)
checkError(err)
}

func checkError(err error) {
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
```
### test.psd
> ![photoshop](https://raw.githubusercontent.com/solovev/gopsd/master/examples/images/readme_preview.png)

### Result

> Background: [X: 0, Y: 0, Width: 384, Height: 512]

GrayRect: [X: -1, Y: 153, Width: 349, Height: 145]

RoundPinkRect: [X: 66, Y: 163, Width: 273, Height: 124]

Ellipse: [X: -58, Y: -89, Width: 338, Height: 212]

SOME TEXT: [X: 18, Y: 18, Width: 235, Height: 34]

| Layers |
| ------------- |
| Background |
| Background |
| GrayRect |
| GrayRect |
| RoundPinkRect |
| RoundPinkRect |
| Ellipse |
| Ellipse |
| SOME TEXT |
| SOME TEXT |