GithubHelp home page GithubHelp logo

chilli-axe / mtg-photoshop-automation Goto Github PK

View Code? Open in Web Editor NEW
55.0 3.0 40.0 48.34 MB

Photoshop scripting to generate high-quality Magic card renders, inserting Scryfall data into Photoshop frame templates.

License: GNU General Public License v3.0

JavaScript 97.93% Python 2.07%

mtg-photoshop-automation's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mtg-photoshop-automation's Issues

Error 23 No matter what i do after PS Update

Hi so I recently updated from CC 2019 to 2020 and ever since I haven't been able to get the script to create the card.json file and run properly. Prior to the update it would run just fine, and I had made many cards using it. Immediately after the update I was able to get the script to run, but it wouldn't update the card.json so it was just using the last successful card's text over and over. In response to this I enabled all permissions both on the scripts folder itself, as well as the folder containing the scripts folder, to no avail. After that I tried redownloading the distro and when I tried running the new file it wouldn't run at all, and only resulted in Error 23 repeatedly which is very frustrating lol. I tried basically everything I could think of to get it to run properly, including following the recommendations of one of the other issues on this git, also to no avail. Is there anything anyone can think of that might be causing this, or a solution I could apply? I'd love to get back to making more cards asap. Thanks!

Text layers on some templates are `corrupted`

Hi @ndepaola

Thanks for the hard work you have done here, I attempted to do the same thing a while back and failed miserably.

Anyways, I found an issue where I on the normal.psd, if I changed a textItem.size, it would not be the number I set it too. I found this Adobe Photoshop thread and it solved the issue for me.

The problem is with textlayers that have been transformed. You have to remake them to solve the issue.

You can use this code to see if the layers are "corrupted":

var filePath = File($.fileName).parent.parent.fsName;

function makeLogFile() {
  // make logfile
  var logFolder = new Folder(filePath + "/logs");
  logFolder.create();

  var logFile = new File(filePath + "/logs/" + "log.log");
  logFile.open("w", "TEXT");
  logFile.close();
}

makeLogFile();

function log(s) {
  var logFile = new File(filePath + "/logs/" + "log.log");
  if (s === undefined) s = "";
  logFile.open("a", "TEXT");
  logFile.write(s + "\n");
  logFile.close();
}

function main() {
  var templates = [
    "normal",
    "normal-boxtopper",
    "womensday"
  ];
  for (var i = 0; i < templates.length; i++) {
    doesTemplateContainTransformedTextlayers(templates[i]);
  }
}

function logFontSizes(template) {
  log(template);
  log()
  var templateLocation = filePath + "/templates/";
  var templatePath = templateLocation + template + ".psd";

  app.open(new File(templatePath));
  var docRef = app.activeDocument;
  var textAndIcons = docRef.layers.getByName("Text and Icons");

  var cardNameLayer = textAndIcons.layers.getByName("Card Name");
  var manaCostLayer = textAndIcons.layers.getByName("Mana Cost");
  var typelineLayer = textAndIcons.layers.getByName("Typeline");

  // cardNameLayer.textItem.contents = "Lmao";

  log(docRef.resolution);

  var layers = {
    "nameLayer": cardNameLayer,
    "manaCostLayer": manaCostLayer,
    "typelineLayer": typelineLayer
  };

  for (var key in layers) {
    log(key);
    var layer = layers[key];
    logLayerTextSize(layer);
    layer.textItem.size = layer.textItem.size;
    log("after setting size to itself");
    logLayerTextSize(layer);
  }
}

function doesTemplateContainTransformedTextlayers(template) {
  // bug discussed here
  // https://feedback.photoshop.com/conversations/photoshop/photoshop-cs6-wrong-fontsize-displaying-when-selecting-multiple-text-layers/5f5f45374b561a3d423cde77
  // still happens on my CC 2017 install

  log(template);

  var templateLocation = filePath + "/templates/";
  var templatePath = templateLocation + template + ".psd";

  app.open(new File(templatePath));
  var docRef = app.activeDocument;

  var textAndIcons = docRef.layers.getByName("Text and Icons");
  var legal = docRef.layers.getByName("Legal");

  var textGroupLayers = [textAndIcons, legal];

  var allLayersArePassing = true;
  for (var i = 0; i < textGroupLayers.length; i++) {
    var layerGroup = textGroupLayers[i];
    log("=== " + layerGroup.name);

    for (var j = 0; j < layerGroup.artLayers.length; j++) {
      var layer = layerGroup.artLayers[j];
      if (layer.kind == LayerKind.TEXT) {
        var failed = isTextLayerTransformed(layer);
        if (failed) {
          allLayersArePassing = false;
          log("FAILED: " + layer.name);
          // } else {
          //   log("PASSED: " + layer.name);
        }
      }
    }
  }
  log("allLayersPassing? " + allLayersArePassing);
  log();
}

function isTextLayerTransformed(textLayer) {
  var initialSize = textLayer.textItem.size;
  textLayer.textItem.size = initialSize;

  return initialSize != textLayer.textItem.size;
}

I've got some other improvements and fixes, but I need copies of the un-rasterized templates found on the g-drive. Do you still have them? It will make the automation way faster.

I've also managed to automate the womensday.psd template, it's just that I have modified the other functions too much, it would break the other templates' code (which I could fix with the un-rasterized templates).

Thanks for your hard work (writing formatText.jsx would have driven me insane!)
CoffeeKing

Borderify Broken Using Newest Templates

I pulled the latest changes from the repo and updated the automated templates to match. Using borderifyAll.jsx, my borderified output is now looking like this:

image

This is for a render that started like this:
image

I'm using:
PhotoShop CS6
Windows 10

Error 23: ) does not have a value

I keep returning the titled error whenever I run the proxy_target script. If I run the proxy_all script I get no response. The get_card_info.py also returns this response: The document “get_card_info.py” could not be opened. IDLE cannot open files in the “Python Script” format. I tried running the permissions fix suggested in the FAQ but it can't locate the card.json. I also tried redownloading the repo but to no avail.
I'm using python 3.9.6 on a mac 11.3.1.

Issues with Planeswalkers

Tried doing two different cards for planeswalkers, extracted from artofmtg and scryfall with no luck
Gives me the error and what photoshop outputs:
Error
Photos I am using can go straight into PS no problem, hoping to find a solution

Misaligned mana cost

First off, just wanted to say what a great tool this is! Thanks for sharing it with the community.

I'm running into a slight issue where the mana cost is misaligned when running the main proxy script. I was curious if you had any ideas on what might be causing this?

I'm running this on Windows 10 with Photoshop CS6 if that helps!

image

Name of the card, mana cost and flavor text misaligned

Hello,
The script seems to works just fine, but the name of the card and mana cost are misaligned off the card.
The flavor text is weirdly cutted, see the pictures to see what i mean.
Any ideas on how to fix it?

https://imgur.com/a/dydWgRW

Windows 10
Photoshop CS6 13.0.1 x32

PS: Also, any ideas on how to change the language of the cards since scryfall also provides infos in other languages.

No mana symbols

I can't seem to find the mana symbol font which is stated to be included in the repo.

Error occurs when generating planeswalker cards

The following error always occurs when trying to generate a planeswalker card:

image

The art is not a problem, as I can use the same art, give it the name of a creature and the card generates perfectly.

Cant get scripts to run

I have everything installed, including Python packages.
However, I have Adobe ExtendedScrript Toolkit installed, and it keeps opening in that.
I've tried opening via python.exe, but won't run at all.

[Feature request] Automatically load artist names

Hi bud,

I was wondering if you could integrate functionality for the Python script to automatically get the artist name and put it on the card.

This will probably need to be an optional flag, I imagine plenty of people use alternative art work.
Perhaps you could do it as a fallback, i.e: if there is no (artist name) found on the image file name, use the artist from the scryfall API.

I dug through the docs, and found this:
https://scryfall.com/docs/api/cards
Under 'print fields' it shows artist.

Think this is something implementable?

Error 1233 Expected a reference to an existing File/Folder

Hello! Sorry if this has been asked before, but I am encountering this issue if I try to render planeswalkers or saga cards. These scripts work amazing for any other card type, but if you could direct me to a fix this would be incredible. Thanks!

Error 1233: Expected a reference to an existing File/Folder

Line: 389
-> app.load(file)

It seems to be coming from the paste_file() function in helpers.jsx

Issue: resolving artist font to custom NDPMTG font results in weird text

Hi there,

I downloaded all the fonts as described. When running the proxyAll script, a message popped up that the MTG2016 font could not be resolved. I checked your FAQ and followed the steps. I opened up the normal.psd and resolved the Artist font (which was showing an error) to the NDPMTG font. This is then the text at the bottom of the card:

image

What am I doing wrong?

Image misaligned

Having issues with the program outputting this:
Malcolm, Keen-Eyed Navigator
Any way to resolve this? Not sure which component of the coding is causing this error. Tried on another card, same result

How I resolved Error 23 and 8800

At the moment, I can't provide a spoonfeed answer but I did resolve it by editing proxy.jsx in the os search snippet (line 36 ish)

if ($.os.search(/windows/i) != -1) { app.system("echo python \"C:/Users/<USER>/Downloads/Adobe Photoshop CC 2019/Photoshop.20/App/Ps/Presets/Scripts/get_card_info.py\"" + " \"" + cardName + "\"" + " > C:/mtg-autoproxy-master/appsysbyp.bat") $.sleep(250) var bat = new File("C:/mtg-autoproxy-master/appsysbyp.bat"); bat.execute(); } else { // macOS app.system("/usr/local/bin/python3 " + filePath + "/scripts/get_card_info.py \"" + cardName + "\" >> " + filePath + "/scripts/debug.log 2>&1"); }

Yes it's ugly, but basically you use app.system to create a .bat file with correct paths and you use execute to run the get_card_info.py to get a json file

Spent 6 hours to create this hideous mess, hopefully it helps out some others.
#3

Crash when card text is too long

HI,
Photoshop crashes for some cards like God-Eternal Kefnet or Lich's Mastery which have long rule text. I tried to find out how to correct this error but I can't.

Error 23: ) does not have a value

image

Im getting this error when running anything that runs proxy.jsx.
Did some logging and it seems to happen on line 43:

var jsonParsed = JSON.parse(JSON.parse(cardJSON));

Any log before this will print fine, any log after will not.

Error 23: ) does not have a value. Line 1

Edit: Never mind, I tried it again and it works now, I don't think I did anything though.

I tried the fixes for this but I'm on windows and the chmod fix seems to be a mac thing.
I know very little about coding so that doesn't help, it could be a simple fix that I don't know about.
Can anyone help?

Windows 10 Pro 20H2

Photoshop 22.0.1

Python 3.9

Multiple reminder text, only one italicized

Someone brought to my attention that cards with two separate instances of reminder text will only render the first text in italics but not the second, I've included an example image. Trying to find other cards to replicate this with but I don't think there are many cards with this situation
Timeless Dragon

Suggestion/question

Hi I'm trying to make some CUSTOM personally made mtg cards and print them, I've been using the autoproxy tool for sometime to print my normal proxies and thought to myself, surely if I could give the tool a set of my own cards information the resulting image would be much better and more consistent than a custom card created on cardsmith for example (which looks ugly in my opinion). Is there a way to easily feed the tool custom card info rather than pulling from scryfall? Could that be an additional script included with release? Thanks! :)

Photoshop Error 8800

Script seems to run for the most part, but crashes before the file renaming.
Only way I have found around this is to manually rename the files, but I was hoping that it might be able to be automated as well.

I have looked into cryzies issue as well, but it appears that the code is very different in the new version.
unknown

Could not complete the command because the selected area is empty

Hi bud,

Firstly, I really appreciate the effort you've put in and continue to put in. I recently started to get into Magic and learned about proxies - that got me really excited.

I'm trying to get you script to work, unfortunately I'm stuck on these errors:
Screenshot 2019-11-15 at 11 52 09
Screenshot 2019-11-15 at 11 52 18

These errors happen after I run "proxyAll.jsx". I've had to make adjustments to the scripts. Mostly file references that I had to hardcode. I cloned your repo a few days ago.

What sort of information do you need to help me to debug this?

I am on MacOS Catalina, using Photoshop CC 2018.

Overlapping text (possible fix found)

using windows 10/photoshop CC2018. All fonts are installed and using a fresh pull and fresh template download. Running the script results in a lot of overlap in text boxes. This seems to happen using both normal and boxtopper cards.
image
image
image

Script References Non-Existent PSDs

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?

Zendikar MDFC Templates

Hi, I wanted to make some proxies for the new Zendikar MDFCs so I wouldn't have to pull the cards out of their sleeves all the time. I tried to make them manually with your tf-templates but I got stuck on the MDFC-indicator in the top left. It seems like you have already made some MDFC-Proxies. Could you please upload your new templates on Google Drive? Cheers!

Error 8800 Rendering King of the Pride (CS6)

I'm trying to make a render of the King of the Pride card using the latest code and Photoshop CS6. Pretty much every other kind of card works without issue (land, legendary, planeswalker, full art land, etc.), but I'm getting an error with this card specifically:
image

What is strange is that this card doesn't appear to be any different than other vanilla cards, so I'm not sure why an error would occur only for it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.