chilli-axe / mtg-photoshop-automation

Photoshop scripting to generate high-quality Magic card renders, inserting Scryfall data into Photoshop frame templates.
GNU General Public License v3.0
60 stars 39 forks source link

Photoshop Error 8800 #12

Closed Yellow-Pelicon closed 4 years ago

Yellow-Pelicon commented 4 years ago

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

ndepaola commented 4 years ago

This never used to be an issue on my machine until tonight - I think I've nailed down the cause of this though (finally, it's been reported for MONTHS but I've never been able to reproduce it):

function verticallyFixText(textLayer) {
  // Make a selection of the text layer that's above the P/T box, then ctrl-j
  // the selection from the card text layer

  // Make selection from the reference layer
  var textAndIcons = app.activeDocument.layers.getByName("Text and Icons");
  var ptAdjustmentReference = textAndIcons.layers.getByName("PT Adjustment Reference");

  var left = ptAdjustmentReference.bounds[0].as("px");
  var top = ptAdjustmentReference.bounds[1].as("px");
  var right = ptAdjustmentReference.bounds[2].as("px");
  var bottom = ptAdjustmentReference.bounds[3].as("px");
  app.activeDocument.selection.select([
    [left, top],
    [right, top],
    [right, bottom],
    [left, bottom]
  ]);

  // Only proceed here if the text layer potentially needs to be shifted up
  // (If the text isn't long enough, the code will error when attempting to ctrl J)
  if (getRealTextLayerDimensions(textLayer).width + textLayer.bounds[0] < left) return;

  // get PT Top Reference layer
  var ptTopReference = textAndIcons.layers.getByName("PT Top Reference");

Specifying that left, right, top and bottom should be in pixels seems to do the trick. Let me know if this works on your end pls <3

Yellow-Pelicon commented 4 years ago

The fix seems to be working great! Thank you!

ndepaola commented 4 years ago

Perfect! Closing this thread :)