GithubHelp home page GithubHelp logo

Comments (6)

ndepaola avatar ndepaola commented on June 27, 2024

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.

duxprime avatar duxprime commented on June 27, 2024

It was already artScaleFactor = 50. I tried changing it to 25, and the render comes out like:
image

FWIW, this was working correctly before pulling the latest changes, so maybe it's a code change?

from mtg-photoshop-automation.

HMPoweredMan avatar HMPoweredMan commented on June 27, 2024

Same issue in the classic branch

from mtg-photoshop-automation.

HMPoweredMan avatar HMPoweredMan commented on June 27, 2024

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.

duxprime avatar duxprime commented on June 27, 2024

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.

duxprime avatar duxprime commented on June 27, 2024

I created a PR to fix this. #11

from mtg-photoshop-automation.

Related Issues (20)

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.