• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..26-Oct-2021-

color/H26-Oct-2021-328281

.gitignoreH A D26-Oct-20218 21

LICENSEH A D26-Oct-20211 KiB2116

README.mdH A D26-Oct-20212.6 KiB138109

blendmode.goH A D26-Oct-20212.9 KiB10493

colormode.goH A D26-Oct-2021862 3525

compress.goH A D26-Oct-20212.5 KiB10183

compress_js.goH A D26-Oct-2021889 4132

compress_other.goH A D26-Oct-20212 KiB114104

compress_wasm_js.goH A D26-Oct-20211.4 KiB8172

imageres.goH A D26-Oct-20213.4 KiB11879

layer.goH A D26-Oct-202123 KiB878736

picker.goH A D26-Oct-202112.9 KiB457406

psd.goH A D26-Oct-20218.2 KiB314255

util.goH A D26-Oct-20213.1 KiB159140

README.md

1# PSD/PSB(Photoshop) file reader for Go programming language
2
3It works almost well but it is still in development.
4
5## How to use
6
7### Example1
8
9Simple psd -> png conversion.
10
11```go
12package main
13
14import (
15	"image"
16	"image/png"
17	"os"
18
19	_ "github.com/oov/psd"
20)
21
22func main() {
23	file, err := os.Open("image.psd")
24	if err != nil {
25		panic(err)
26	}
27	defer file.Close()
28
29	img, _, err := image.Decode(file)
30	if err != nil {
31		panic(err)
32	}
33
34	out, err := os.Create("image.png")
35	if err != nil {
36		panic(err)
37	}
38	err = png.Encode(out, img)
39	if err != nil {
40		panic(err)
41	}
42}
43```
44
45### Example2
46
47Extract all layer images.
48
49```go
50package main
51
52import (
53	"fmt"
54	"image/png"
55	"os"
56
57	"github.com/oov/psd"
58)
59
60func processLayer(filename string, layerName string, l *psd.Layer) error {
61	if len(l.Layer) > 0 {
62		for i, ll := range l.Layer {
63			if err := processLayer(
64				fmt.Sprintf("%s_%03d", filename, i),
65				layerName+"/"+ll.Name, &ll); err != nil {
66				return err
67			}
68		}
69	}
70	if !l.HasImage() {
71		return nil
72	}
73	fmt.Printf("%s -> %s.png\n", layerName, filename)
74	out, err := os.Create(fmt.Sprintf("%s.png", filename))
75	if err != nil {
76		return err
77	}
78	defer out.Close()
79	return png.Encode(out, l.Picker)
80}
81
82func main() {
83	file, err := os.Open("image.psd")
84	if err != nil {
85		panic(err)
86	}
87	defer file.Close()
88
89	img, _, err := psd.Decode(file, &psd.DecodeOptions{SkipMergedImage: true})
90	if err != nil {
91		panic(err)
92	}
93	for i, layer := range img.Layer {
94		if err = processLayer(fmt.Sprintf("%03d", i), layer.Name, &layer); err != nil {
95			panic(err)
96		}
97	}
98}
99```
100
101# Current status
102
103It is not implemented any blending functions because layer composition isn't covered by this package at present.
104
105- [Image Resource Section](http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_69883) is parsed but [Image resource IDs](http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_38034) are not defined as constant.
106- [Global layer mask info](http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_17115) is not parsed.
107- [Layer blending ranges data](http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_21332) is not parsed.
108- [Additional Layer Information](http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_pgfId-1049436) is parsed but keys are almost not defined as constant.
109
110## Color Modes
111
112### Implemented
113
114- Bitmap 1bit
115- Grayscale 8bit
116- Grayscale 16bit
117- Grayscale 32bit
118- Indexed
119- RGB 8bit
120- RGB 16bit
121- RGB 32bit
122- CMYK 8bit
123- CMYK 16bit
124
125### Not implemented
126
127- CMYK 32bit
128- Multichannel
129- Duotone
130- Lab
131
132## Supported Compression Methods
133
134- Raw
135- RLE(PackBits)
136- ZIP without prediction (not tested)
137- ZIP with prediction
138