Last active
March 9, 2022 19:26
-
-
Save opengeek/8721056df91449cd2e1897aed7de7c05 to your computer and use it in GitHub Desktop.
Use Photoshop scripting to adjust any image that exceeds Instagram aspect ratios by padding the canvas size with white background color.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var docRef = app.activeDocument; | |
var currentWidth = docRef.width; | |
var currentHeight = docRef.height; | |
var aspectRatio = currentWidth / currentHeight; | |
var mycolor = new SolidColor(); | |
mycolor.rgb.hexValue = "ffffff"; | |
app.backgroundColor = mycolor; | |
if (aspectRatio < 0.8) { | |
var paddedWidth = currentHeight * 0.8; | |
docRef.resizeCanvas(paddedWidth, currentHeight, AnchorPosition.MIDDLECENTER); | |
} else if (aspectRatio > 1.91) { | |
var paddedHeight = currentWidth * 1.91; | |
docRef.resizeCanvas(currentWidth, paddedHeight, AnchorPosition.MIDDLECENTER); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment