Advertisement
Guest User

MaxCanvas.jsx for Photoshop

a guest
Jan 14th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // K Baker @ 14.01.2014 11:21:01
  2.     // Resize canvas to largest size in Photoshop
  3.     // Tested only in Photoshop CC on Maverics
  4.      
  5.     // Enable double clicking from the Macintosh Finder or the Windows Explorer
  6.     #target photoshop
  7.      
  8.     // If double clicked, bring app to front
  9.     app.bringToFront();
  10.      
  11.     if (documents.length > 0) {
  12.            
  13.             // Get original height and width
  14.            
  15.             originalWidth = app.activeDocument.width;
  16.             originalHeight = app.activeDocument.height;
  17.      
  18.             // Resize canvas to the largest size
  19.            
  20.             if (originalWidth > originalHeight) {
  21.                    
  22.                     newWidth = originalWidth;
  23.                     newHeight = originalWidth;
  24.                    
  25.             } else if (originalHeight > originalWidth) {
  26.                    
  27.                     newWidth = originalHeight;
  28.                     newHeight = originalHeight;
  29.                    
  30.             } else {
  31.            
  32.                     // There's really nothing to do here, as the height and width aparently are the same size      
  33.                    
  34.             }
  35.            
  36.             app.activeDocument.resizeCanvas(newWidth, newHeight, AnchorPosition.MIDDLECENTER);
  37.            
  38.     } else {
  39.      
  40.             alert("You must have at least one open document to run this script!");
  41.            
  42.     }
  43.      
  44.     // EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement