chilli-axe / mtg-photoshop-automation Goto Github PK
View Code? Open in Web Editor NEWPhotoshop scripting to generate high-quality Magic card renders, inserting Scryfall data into Photoshop frame templates.
License: GNU General Public License v3.0
Photoshop scripting to generate high-quality Magic card renders, inserting Scryfall data into Photoshop frame templates.
License: GNU General Public License v3.0
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!
Would it perhaps be possible to add a feature that allows the scryfall api to automatically get the expansion name of the card, then find the appropriate symbol from: https://andrewgioia.github.io/Keyrune/icons.html and set it on the card?
I imagine a dictionary with the expansion name as key and the icon as value would help.
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
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.
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!
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?
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.
I can't seem to find the mana symbol font which is stated to be included in the repo.
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.
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?
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
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:
What am I doing wrong?
Getting an error when I go to bordify cards, been fiddling around with all this stuff to get this all to work so I apologize if its an obvious fix or something as im new to all this.
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
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.
Support for classic card borders would be great for making themed classic proxy decks.
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
See two examples here: https://imgur.com/a/FJfE71j
Have tried nailing down in the code where/how the scaling happens but haven't quite figured it out.
OSX
Photoshop 21.1.1
Using Photoshop CC 2020
No error messages or information of any kind, it just starts the automation process and from what I can tell, right after going through the fonts it just closes the template.
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! :)
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.
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:
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.
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:
.
If I hardcode these paths to reference the provided Template.psd
, the output is mostly correct, but a few things are off:
card.json
(although it works correctly when manually executed from bash)Should there be additional templates in the repo? Or should new File()
create one if it doesn't exist?
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!
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:
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.