Comments (6)
could you try changing the value of 'artScaleFactor` in 'excessFunctions' from 100 to 50, then see if that makes a difference? I suspect this is the same bug that causes art to be twice as large when inserted into the card frame. Though if artwork is sized correctly and borderified cards are twice as large as they should be, then I'm not sure what could cause that discrepancy
from mtg-photoshop-automation.
It was already artScaleFactor = 50
. I tried changing it to 25
, and the render comes out like:
FWIW, this was working correctly before pulling the latest changes, so maybe it's a code change?
from mtg-photoshop-automation.
Same issue in the classic branch
from mtg-photoshop-automation.
The image height and width need to specify pixels. They may be defaulted to inches for most people.
Adding back .as("px") for all bounds should do the trick. Scale factor back to 100
You can replace the function "frame" in excessFunctions with this:
function frame(leftPix, topPix, rightPix, bottomPix) {
var docRef = app.activeDocument;
// Get width and height of image
var imageHeight = bottomPix - topPix;
var imageWidth = rightPix - leftPix;
// Get current size of window
var myLayer = docRef.layers.getByName("Layer 1");
var windowHeight = myLayer.bounds[3].as("px") - myLayer.bounds[1].as("px");
var windowWidth = myLayer.bounds[2].as("px") - myLayer.bounds[0].as("px");
// Determine how much to scale the art by, such that it fits into the art window
var percentageToScale = artScaleFactor * (Math.max(imageWidth / windowWidth, imageHeight / windowHeight));
myLayer.resize(percentageToScale, percentageToScale, AnchorPosition.TOPLEFT);
myLayer.move(activeDocument, ElementPlacement.PLACEATEND);
I renamed some variables (swapping image and window) because the current naming was confusing to me but the important part is the addition of .as("px") on the bounds which makes it no longer required in the line:
var percentageToScale = artScaleFactor * (Math.max(imageWidth / windowWidth, imageHeight / windowHeight));
from mtg-photoshop-automation.
This did it for me. Thanks, Kyle!
One thing to note for others looking to fix this: I didn't replace the entire frame()
function with @HMPoweredMan's implementation wholesale. This didn't work in CS6 so I used the existing implementation and simply converted to pixels.
var artScaleFactor = 100;
// ...
var imageHeight = myLayer.bounds[3].as("px") - myLayer.bounds[1].as("px");
var imageWidth = myLayer.bounds[2].as("px") - myLayer.bounds[0].as("px");
var percentageToScale = artScaleFactor * Math.max(windowWidth / imageWidth, windowHeight / imageHeight);
from mtg-photoshop-automation.
I created a PR to fix this. #11
from mtg-photoshop-automation.
Related Issues (20)
- Error 1233: Expected a reference to an existing File/Folder Line: 8 -> app.open(fileRef);
- Misaligned mana cost HOT 3
- Mana symbols and rules text font size are miscalculated (too large) HOT 2
- Cant get scripts to run HOT 2
- Error 23 No matter what i do after PS Update HOT 2
- Error 8800 Rendering King of the Pride (CS6) HOT 2
- normal template crashes/closes when trying to run proxyAll
- Name of the card, mana cost and flavor text misaligned HOT 4
- Suggestion/question
- Zendikar MDFC Templates HOT 2
- Error 23: ) does not have a value. Line 1 HOT 1
- Text layers on some templates are `corrupted` HOT 3
- Overlapping text (possible fix found) HOT 21
- Error 23: ) does not have a value HOT 17
- Image misaligned HOT 2
- Issues with Planeswalkers HOT 2
- Error 1233 Expected a reference to an existing File/Folder HOT 2
- Crash when card text is too long HOT 7
- Error occurs when generating planeswalker cards HOT 1
- Multiple reminder text, only one italicized HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mtg-photoshop-automation.