New** PSD to LUA +PNG exporter (using Director.lua)

I tried both of the scripts on OSX CS5. The exporter script crashed photoshop almost immediately each time. The new_merge version got considerably further before crashing. I had the Sam experience on Photoshop CS5 on Windows 7 running in parallels. I think the issues is still a Mac issue [import]uid: 7664 topic_id: 8337 reply_id: 30660[/import]

UPDATE: Tried the non Merge script just now and it completed succesfully, the Merge script did produce an error! [import]uid: 7664 topic_id: 8337 reply_id: 30663[/import]

Tried to export the test.psd again and it crashed photoshop, I didn’t do anything differently [import]uid: 7664 topic_id: 8337 reply_id: 30664[/import]

@TechnicalSamuraiMac: Yes, exporter now works in CS5 Mac!

However the demo PSD exports fine but the simulator complains of director being missing… [import]uid: 33866 topic_id: 8337 reply_id: 30665[/import]

@CL-Apps - Yeah i don’t generate Director or UI, if you look in the CPM folder i put up you will see the versions I used, when I update to newer versions of each I will put them in there again.

So hard to fix a script that breaks on some and not on others :confused: [import]uid: 33265 topic_id: 8337 reply_id: 30667[/import]

@Runseld - I had hoped the merge would be the fix all script as my latest one. If you are running the extender to run the script could you possible paste the console output (top right panel) to a post so I could inspect it cheers.

TS [import]uid: 33265 topic_id: 8337 reply_id: 30668[/import]

UPDATE: Just exported again and although the exporter complained of files being ‘unavailable’ I have managed to export a couple of times.

After throwing director.lua, ui.lua and some build settings that set the screen to landscape the demo PSD worked! and the clickable button worked.

[import]uid: 33866 topic_id: 8337 reply_id: 30669[/import]

Update: Mixed results - First run of Exporter ran without a hitch.
Second Run - errored out with the following message

Starting the export using version 0.0.39
Windows
Create folders…
SCENE - scene1
MERGEDGROUP :scene1->backgroundimg.png
Saving Merged Layer
ArtLayer

Exproter_newMerge results as follows

Error with following output

Starting the export using version 0.0.391
Windows
Create folders…
SCENE - scene1
MERGEDGROUP :scene1->backgroundimg.png
temp layer name is 1301921755483
– Called savePNGLayer –
–Select the layer by name --1301921755483
–Creating a new document of width and height 480 320
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/export/images/backgroundimg.png
–Add the file to the close list–
SCENEIMAGE:scene1->title.png
temp layer name is 1301921757465
– Called savePNGLayer –
–Select the layer by name --1301921757465
–Creating a new document of width and height 368 15
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/export/images/title.png
–Add the file to the close list–
SCENEIMAGE:scene1->textbody.png
temp layer name is 1301921758486
– Called savePNGLayer –
–Select the layer by name --1301921758486
–Creating a new document of width and height 271 229
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/export/images/textbody.png
–Add the file to the close list–
BUTTONGROUP:scene1->test_1_
temp layer name is 1301921759655
– Called savePNGLayer –
–Select the layer by name --1301921759655
–Creating a new document of width and height 146 35
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/export/images/exampleBut_touch_.png
–Add the file to the close list–
temp layer name is 1301921760442
– Called savePNGLayer –
–Select the layer by name --1301921760442
–Creating a new document of width and height 146 35
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/export/images/exampleBut_default_.png
–Add the file to the close list–
Your file was saved at ~/Desktop/export/scene1.lua
SCENE - scene2
SCENEIMAGE:scene2->Layer1.png
temp layer name is 1301921761257
– Called savePNGLayer –
–Select the layer by name --1301921761257
–Creating a new document of width and height 480 320
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/export/images/Layer1.png
–Add the file to the close list–
BUTTONGROUP:scene2->test_2_
1
temp layer name is 1301921763609
– Called savePNGLayer –
–Select the layer by name --1301921763609
–Creating a new document of width and height 146 35
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/export/images/exampleBut_touch__1_.png
–Add the file to the close list–
1
temp layer name is 1301921765058
– Called savePNGLayer –
–Select the layer by name --1301921765058
–Creating a new document of width and height 146 35
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/export/images/exampleBut_default__1_.png
–Add the file to the close list–

Sidenote - I am still very excited about this tool and really appreciate the amount of work you are putting in to its development [import]uid: 7664 topic_id: 8337 reply_id: 30670[/import]

@Runseld - Im glad you are excited. looking at your log i think we’re looking at a new issue here, this is crashing after the png exports and this time its probably crashing at the creation of the .lua files.

I’ll add more traces tonight or tomorrow and let you know when the new version is ready to test, hopefully we can pinpoint which save it has a problem with.

I wonder IF you make a point of deleting the export folder and its contents and run again does it work again? Might be a write permissions setting on the OS?

Cheers [import]uid: 33265 topic_id: 8337 reply_id: 30673[/import]

I was thinking something similar, It will run the test the first time in any folder, after which it will only create a main.lua file and the quit. If I delete the export folder it will either crash or just create a main.lua file. However, I have to restart Photoshop between runs or it will crash right away [import]uid: 7664 topic_id: 8337 reply_id: 30674[/import]

Update, to get it to initialize the script I have to change the filename to something new each time. I have tried to find the cache in photoshop and delete, but I am not sure I even deleted the right cache file [import]uid: 7664 topic_id: 8337 reply_id: 30675[/import]

Hmmm I might be able to use this information. Cheers will get back if i can find a way to clear cache via code… it might be a clipboard error… [import]uid: 33265 topic_id: 8337 reply_id: 30771[/import]

Version 0.0.392 is now up, merge version…

I’ve added more traces and also a purge of caches to see if this can simulate what Runseld is simulating by renaming the file each time.

Let me know… [import]uid: 33265 topic_id: 8337 reply_id: 30868[/import]

Photoshop crashes when I run the script. I’ve tried it in CS5 on a Mac Intel Machine as well in CS4 on a quadcore G5. I’m using your test.psd file. Is there anything I can send to you that might explain the crashes?

Jerry [import]uid: 39859 topic_id: 8337 reply_id: 31009[/import]

There is the extender script program which runs with this. It will have a console on the top right. If you could copy and paste its contents after one run into this blog I can use it for clues.

Cheers [import]uid: 33265 topic_id: 8337 reply_id: 31070[/import]

Downloaded the new Scripts, here are my results

Non Merge Script


Worked Fine on First Run!!!
Second Run
Crashed Immeadiately
Third Run, Renamed File
Starting the export using version 0.0.39
Windows
Create folders…
SCENE - scene1
MERGEDGROUP :scene1->backgroundimg.png
Saving Merged Layer
ArtLayer

The Merge Script


First Run
Photoshop Crashed:
Console Output

Starting the export using version 0.0.392
Purging Cache from Photoshop
Create folders…
SCENE - scene1
MERGEDGROUP :scene1->backgroundimg.png
temp layer name is 1302190046110
– Called savePNGLayer –
–Select the layer by name --1302190046110
–Creating a new document of width and height 480 320
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/KevCJones-Photoshop-to-Corona-Exporter-41ce560/psd/export/images/backgroundimg.png
–Add the file to the close list–
–Completed the adding to close list…next graphic go!–
–Layer name restored back to backgroundimg_merge_
–Generate inser code
SCENEIMAGE:scene1->title.png
temp layer name is 1302190048290
– Called savePNGLayer –
–Select the layer by name --1302190048290
–Creating a new document of width and height 368 15
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/KevCJones-Photoshop-to-Corona-Exporter-41ce560/psd/export/images/title.png
–Add the file to the close list–
–Completed the adding to close list…next graphic go!–
–Layer name restored back to title
–Generate insert code
SCENEIMAGE:scene1->textbody.png
temp layer name is 1302190049412
– Called savePNGLayer –
–Select the layer by name --1302190049412
–Creating a new document of width and height 271 229
Second RUN
Crash Immediately

Third Run, renamed file to tested.psd
Crashed

Console Output
Starting the export using version 0.0.392
Purging Cache from Photoshop
Create folders…
SCENE - scene1
MERGEDGROUP :scene1->backgroundimg.png
temp layer name is 1302190285640
– Called savePNGLayer –
–Select the layer by name --1302190285640
–Creating a new document of width and height 480 320
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–

[import]uid: 7664 topic_id: 8337 reply_id: 31111[/import]

Here you go!

Non Merge

Starting the export using version 0.0.39
Windows
Create folders…
SCENE - scene1
MERGEDGROUP :scene1->backgroundimg.png
Saving Merged Layer
ArtLayer

Merge

Starting the export using version 0.0.392
Purging Cache from Photoshop
Create folders…
SCENE - scene1
MERGEDGROUP :scene1->backgroundimg.png
temp layer name is 1302204051545
– Called savePNGLayer –
–Select the layer by name --1302204051545
–Creating a new document of width and height 480 320
–Pasting the copied clipboard data–
–Resizing the canvas to add padding–
–Save the image as a PNG --~/Desktop/KevCJones-Photoshop-to-Corona-Exporter-41ce560/psd/export/images/backgroundimg.png

[import]uid: 39859 topic_id: 8337 reply_id: 31134[/import]

Just a quick note to those who are still interested in having a working version of this script apart from me ;). Yeah that busy week turned into a super busy fortnight and its still a little crazy so I have had to shelve my extra hours work on this. But fear not… I have some time off work coming up and I’ll be making sure I can use this script and improving it as I do so that I can create a game using it.

So hopefully by then we can get things ironed out. If there any developers who to contribute, i’m not precious just let me know and i’ll work out on Github how i can let you branch builds and we can merge trunks down the line.

TS [import]uid: 30931 topic_id: 8337 reply_id: 32869[/import]

Looking forward to it.

Jerry [import]uid: 39859 topic_id: 8337 reply_id: 32872[/import]

This is great! How difficult would it be to add a tag for _text_? I.e., output display.newText lines with the appropriate size, coordinates, colour, font, etc. ?

Edit:
I guess the issue here is with line breaks – I suppose there is the potential of creating a new display.newText object for each line. I don’t know how difficult it is to extract that from the PSD. Perhaps in the future if ansca allows for multiline newText objects similar to native.newTextBox…

2nd Edit:
Haha I guess I should look around a bit more before posting. According to the blog, newText objects do allow multiline text as of the latest build (http://blog.anscamobile.com/2011/10/multiple-lines-in-display-newtext/)

display.newText( string, x, y, [w, h,] font, size )

local multiText = display.newText( “This text should be wrapped according to the specified width.”, 25, 25, 175, 400, “Helvetica”, 18 )
multiText:setTextColor( 0 ) [import]uid: 87249 topic_id: 8337 reply_id: 66819[/import]