mirror of
https://github.com/sbrow/ps.git
synced 2025-12-29 18:47:38 -05:00
Fixed doc.Dump?
This commit is contained in:
79
v2/Test.json
Normal file
79
v2/Test.json
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"Name": "Test.psd",
|
||||
"FullName": "~/go/src/github.com/sbrow/ps/v2/Test.psd",
|
||||
"Height": 600,
|
||||
"Width": 900,
|
||||
"ArtLayers": [
|
||||
{
|
||||
"Name": "Background",
|
||||
"Bounds": [
|
||||
[
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
900,
|
||||
600
|
||||
]
|
||||
],
|
||||
"Color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"Stroke": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"StrokeAmt": 0,
|
||||
"Visible": true,
|
||||
"TextItem": null
|
||||
}
|
||||
],
|
||||
"LayerSets": [
|
||||
{
|
||||
"Name": "Group 1",
|
||||
"Bounds": [
|
||||
[
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0
|
||||
]
|
||||
],
|
||||
"Visible": true,
|
||||
"ArtLayers": [
|
||||
{
|
||||
"Name": "Layer 1",
|
||||
"Bounds": [
|
||||
[
|
||||
222,
|
||||
290
|
||||
],
|
||||
[
|
||||
472,
|
||||
454
|
||||
]
|
||||
],
|
||||
"Color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"Stroke": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"StrokeAmt": 0,
|
||||
"Visible": true,
|
||||
"TextItem": null
|
||||
}
|
||||
],
|
||||
"LayerSets": []
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
v2/Test.psd
BIN
v2/Test.psd
Binary file not shown.
@@ -130,16 +130,16 @@ func ActiveDocument() (*Document, error) {
|
||||
log.Println("Loading ActiveDocument")
|
||||
d := &Document{}
|
||||
|
||||
byt, err := DoJS("activeDocName.jsx")
|
||||
byt, err := DoJS("activeDocFullName.jsx")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d.name = strings.TrimRight(string(byt), "\r\n")
|
||||
d.fullName = strings.TrimRight(string(byt), "\r\n")
|
||||
if Mode != Safe {
|
||||
err = d.Restore(d.DumpFile())
|
||||
switch {
|
||||
case os.IsNotExist(err):
|
||||
log.Println("Previous version not found.")
|
||||
log.Printf("Previous version not found: \"%s\"\n", d.DumpFile())
|
||||
case err == nil:
|
||||
return d, err
|
||||
default:
|
||||
@@ -202,6 +202,10 @@ func (d *Document) DumpFile() string {
|
||||
log.Println(err)
|
||||
}
|
||||
path := filepath.Join(strings.Replace(d.fullName, "~", usr.HomeDir, 1))
|
||||
path = strings.TrimPrefix(path, `\`)
|
||||
path = strings.Replace(path, `[^:]\`, `:\`, 1)
|
||||
drive := filepath.VolumeName(path)
|
||||
path = strings.Replace(path, drive, strings.ToUpper(drive), 1)
|
||||
return strings.Replace(path, ".psd", ".json", 1)
|
||||
}
|
||||
|
||||
|
||||
1
v2/ps.go
1
v2/ps.go
@@ -141,6 +141,7 @@ func Quit(save SaveOption) error {
|
||||
}
|
||||
|
||||
// SaveAs saves the Photoshop document to the given location.
|
||||
// // TODO(sbrow): doesn't return error on non-existant path.
|
||||
func SaveAs(path string) error {
|
||||
_, err := runner.Run("save", path)
|
||||
return err
|
||||
|
||||
2
v2/runner/scripts/activeDocFullName.jsx
Normal file
2
v2/runner/scripts/activeDocFullName.jsx
Normal file
@@ -0,0 +1,2 @@
|
||||
#include lib.js
|
||||
var stdout = newFile(arguments[0]);stdout.writeln(app.activeDocument.fullName);stdout.close();
|
||||
@@ -1,4 +1,5 @@
|
||||
#include lib.js
|
||||
alert(app.activeDocument.path)
|
||||
var f = newFile(arguments[0]);
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
f.writeln(arguments[i]);
|
||||
|
||||
10
v2/test.log
Normal file
10
v2/test.log
Normal file
@@ -0,0 +1,10 @@
|
||||
2018/08/20 17:09:51 Loading ActiveDocument
|
||||
2018/08/20 17:09:51 Previous version not found: "C:\Users\Spencer\go\src\github.com\sbrow\ps\v2\Test.json"
|
||||
2018/08/20 17:09:51 Loading manually (This could take awhile)
|
||||
2018/08/20 17:09:51 Loading ActiveDocument/Group 1/
|
||||
2018/08/20 17:09:51 Dumping to disk
|
||||
2018/08/20 17:09:51 C:\Users\Spencer\go\src\github.com\sbrow\ps\v2\Test.json
|
||||
2018/08/20 17:09:52 Dumping to disk
|
||||
2018/08/20 17:09:52 C:\Users\Spencer\go\src\github.com\sbrow\ps\v2\Test.json
|
||||
2018/08/20 17:09:52 Loading ActiveDocument
|
||||
2018/08/20 17:09:52 Previous version found, loading
|
||||
Reference in New Issue
Block a user