Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script References Non-Existent PSDs #2

Closed
duxprime opened this issue Aug 16, 2019 · 15 comments
Closed

Script References Non-Existent PSDs #2

duxprime opened this issue Aug 16, 2019 · 15 comments

Comments

@duxprime
Copy link
Contributor

duxprime commented Aug 16, 2019

I'm attempting to get your scripts to work with Photoshop CS6. However, I am getting an error from functions like proxyNormal() in proxy.jsx which take a template name as an argument.
It appears that the script is attempting to open a non-existent file:
Annotation 2019-08-15 205218.

If I hardcode these paths to reference the provided Template.psd, the output is mostly correct, but a few things are off:

  • The mana symbols are incorrectly sized
  • The Python script doesn't seem to be executing to generate new card.json (although it works correctly when manually executed from bash)

Wasteland

Should there be additional templates in the repo? Or should new File() create one if it doesn't exist?

@duxprime duxprime changed the title Script References Non-Existant PSDs Script References Non-Existent PSDs Aug 16, 2019
@ndepaola
Copy link
Collaborator

I think I forgot to rename the template on the google drive to normal.psd - if you do that and move it into the templates folder, that should fix your file path issues

With regards to the python script, what bash command are you using to execute it & have it work properly? Is it different to the command defined in the proxy.jsx file?

@duxprime
Copy link
Contributor Author

duxprime commented Aug 18, 2019

It seems like each there are a number of template names that proxyNormal() can take as an argument ("normal", "transform-front", "transform-back"). Should those all point to the template from Google Drive?

As far the Python script, if I run it using the same command proxy.jsx does (e.g.,python get_card_info.py "Force of Will") it works just fine and generates a new card.json. But when ran from the script, one isn't generated and it only continues if I previously manually created one.

I'm wondering if maybe Photoshop CS6 doesn't support the app.system() call. No exceptions are being thrown, though.

@duxprime
Copy link
Contributor Author

duxprime commented Aug 19, 2019

Okay, so I figured some things out.

The Python script wasn't executing because the location where proxy.jsx was searching was the directory of the program executing the script ("C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)"). I changed the call to use an absolute path:

// proxy.jsx
app.system("python " + filePath + "\\scripts\\get_card_info.py \"" + cardName + "\"");

I had a similar issue with the location the Python script would create card.json, so I made that an absolute path as well:

# get_card_info.py
path = os.path.dirname(sys.argv[0]) 
print("Dumping to: " +  path);
with open(path + "\card.json", 'w') as f:
   json.dump(json_dump, f)

However, I'm still seeing some issues in the final output of the cards:

  • The mana symbols are very large
  • The background isn't transparent in the upper left corner
  • The art is getting cropped/zoomed strangely

Force of Will

Wasteland

@ndepaola
Copy link
Collaborator

Hey again,
Glad to see things are working a little better now.

Regarding the mana costs being left justified, I can't recreate that on my end but I may have found where the issue is originating from. Try updating your formatText.jsx file and see if the new version fixes it.

For the sizes of mana costs and artworks, you can adjust the scaling of them in the text. Search for the number 160 in proxy.jsx and try replacing those instances with 80, and see if that fixes the mana cost. For the artwork, you can replace the number 100 on line 44 of frame.jsx with 50, and see if that fixes the artwork scaling issue.

These scaling issues seem to crop up differently on everyone's PC's and I can't seem to recreate them, so this is the best I can do for now :/

(The lack of transparency in the top corners is due to the art scaling incorrectly, so this should fix it. However, in practice that issue doesn't matter anyway, because when adding the print bleed edge, it'll cover up the non-transparent corners.)

There are a number of templates that the code references that I haven't made public - these are still in development, but I use this git for source control in the interim. Adding references to them doesn't break anything, since the main template can't support those card types anyway, so it's not worth adding another branch imo.

I've also made an adjustment to the set symbol gradient function, so that should fix that issue too.

@duxprime
Copy link
Contributor Author

Okay. I pulled your latest changes and made the modifications you suggested. The art seems to be better, but the mana symbols are still offset (even after getting them to a better size).

Any suggestions?

Force of Will

@brd55
Copy link

brd55 commented Nov 11, 2019

@ndepaola I've been following the steps here (except for the change to get_card_info.py, as that made things worse). I'm still getting an error on line 43 of proxy.jsx when it hits var jsonParsed = JSON.parse(JSON.parse(cardJSON));. Any idea what the issue might be?

@ndepaola
Copy link
Collaborator

hey - is get_card_info generating a card.json file? It might be that it's trying to parse an empty json file or something similar. Which card are you trying to run the script for?

@tcasparro
Copy link

tcasparro commented Nov 13, 2019

Here is the code to fix the mana cost positioning. It should go after the formatText() line in the "Mana Cost" section.

    var leftShift = ((cardManaCost.length/3)*70);
    var idmove = charIDToTypeID( "move" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( idLyr, idOrdn, idTrgt );
    desc2.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T   " );
        var desc3 = new ActionDescriptor();
        var idHrzn = charIDToTypeID( "Hrzn" );
        var idRlt = charIDToTypeID( "#Rlt" );
        desc3.putUnitDouble( idHrzn, idRlt, -leftShift );
        var idVrtc = charIDToTypeID( "Vrtc" );
        var idRlt = charIDToTypeID( "#Rlt" );
        desc3.putUnitDouble( idVrtc, idRlt, 0.000000 );
    var idOfst = charIDToTypeID( "Ofst" );
    desc2.putObject( idT, idOfst, desc3 );
    executeAction( idmove, desc2, DialogModes.NO );

@brd55
Copy link

brd55 commented Nov 14, 2019

I'm certainly not seeing any card.json. I've tried with Wasteland and Purphoros. I've tried a few different things with the path, thinking maybe that would work. No luck so far.

@ndepaola
Copy link
Collaborator

The issue might be in your python installation then. Try running the get_card_info script from the command line - change directory into the scripts folder, then try the command python get_card_info.py "Purphoros, God of the Forge", and see what the result is. If everything's set up correctly, that should generate a card.json in the scripts folder.

@brd55
Copy link

brd55 commented Nov 16, 2019

Thanks for the response. That worked just fine from the terminal. And then if I try and run proxyAll, it works fine. So I'm guessing maybe it's not saving card.json in the right directory? Either that or something is wrong with how I'm inputting the card name? For the former, I've tried a few variations, including
# get_card_info.py path = os.path.dirname(sys.argv[0]) print("Dumping to: " + path); with open(path + "\card.json", 'w') as f: json.dump(json_dump, f)

My art name is Purphoros, God of the Forge (Eric Deschamps).jpg

@ndepaola
Copy link
Collaborator

Are you on a Windows computer or a Mac? It seems like the script can run into permissions issues when trying to save card.json on macOS when run through Photoshop, while working from the terminal. On Windows it appears to work fine both ways (at least on my system).

@brd55
Copy link

brd55 commented Nov 17, 2019

I'm running Windows 10, Photoshop CS6. I've even tried running PS as an admin.

@ndepaola
Copy link
Collaborator

Floris Warmenhoven nailed down the source of this issue on macOS a bit earlier today, and I've included the fix in the latest commit. I'm hoping the same issue is occurring on your system so it can be solved in the same way. Could you try downloading the latest version of get_card_info.py and see if anything changes?

@duxprime
Copy link
Contributor Author

duxprime commented Nov 24, 2019

@redsunsoft's code worked for me with the latest changes in the repo to correctly reposition the mana symbols. That solves all of my issues I had when I first opened this, so I'm going to close out this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants