Here's the code you posted before you later removed:
#target photoshop
var destFolder,
sourceFolder,
files,
fileType,
sourceDoc;
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
sourceFolder = Folder.selectDialog('Select the folder that contains the .png files to convert to hoodies');
if (sourceFolder != null) {
files = new Array();
fileType = "*.png";
files = sourceFolder.getFiles(fileType);
if (files.length > 0) {
destFolder = Folder.selectDialog('Select the folder where you want to save the hoodie files');
for(i = 0; i < files.length; i++) {
sourceDoc = app.open(files);
var docRef = sourceDoc;
var fileNameNoExtension = docRef.name;
fileNameNoExtension = fileNameNoExtension.split("." );
if (fileNameNoExtension.length > 1 ) {
fileNameNoExtension.length--;
}
fileNameNoExtension = fileNameNoExtension.join(".");
var suffix = "-Hoodie";
var saveName = new File(destFolder + '/' + fileNameNoExtension + suffix + '.png');
with(docRef) {
var bounds = activeLayer.bounds;
var height = bounds[3].value - bounds[1].value;
var newSize = (100 / height) * 4050;
resizeCanvas(4500, 4050, AnchorPosition.MIDDLECENTER);
resizeImage(newSize, newSize);
sfwPNG24(saveName), close(SaveOptions.DONOTSAVECHANGES)
}
}
}
}
app.preferences.rulerUnits = startRulerUnits;
function sfwPNG24(saveFile) {
var pngOpts = new PNGSaveOptions;
pngOpts.compression = 9;
pngOpts.interlaced = false;
activeDocument.saveAs(saveFile, pngOpts, true, Extension.LOWERCASE);
}
I changed it a little in some parts as that question about wrong resizing images wasn't only one problem. Anyway it still doesn't work the way you wanted. To make it working replace whole with statement with this code:
(function IC(v) {
if (!v) (aD = activeDocument).trim(TrimType.TRANSPARENT);
eval('aD.resize' + (v ||'Image') + '(' + (!(r = ~~((wh = [aD.width, aD.height])[+!!v] / wh[+!v]))
? 'null, ' : '') + '({"true": 4500, "false": 4050})[' + !!r + '])'); if (!v) IC('Canvas')
})()
sfwPNG24(saveName), docRef.close(SaveOptions.DONOTSAVECHANGES)
As to your another question. There may be some 'invisible' px in transparency area? Use trim to to see will anything happen.