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

Borderify Broken Using Newest Templates #10

Closed
duxprime opened this issue Jan 2, 2020 · 6 comments
Closed

Borderify Broken Using Newest Templates #10

duxprime opened this issue Jan 2, 2020 · 6 comments

Comments

@duxprime
Copy link
Contributor

duxprime commented Jan 2, 2020

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

@ndepaola
Copy link
Collaborator

ndepaola commented Jan 3, 2020

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

@duxprime
Copy link
Contributor Author

duxprime commented Jan 3, 2020

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?

@HMPoweredMan
Copy link

Same issue in the classic branch

@HMPoweredMan
Copy link

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));

@duxprime
Copy link
Contributor Author

duxprime commented Jan 5, 2020

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);

@duxprime
Copy link
Contributor Author

duxprime commented Jan 5, 2020

I created a PR to fix this. #11

@duxprime duxprime closed this as completed Jan 7, 2020
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

3 participants