Make Folder Art

From TheAlmightyGuru
Jump to: navigation, search

Make Folder Art is a JScript program that converts the image file passed into it into a 512x512 JPG image named folder.jpg to be used as the album art of a music file. This program requires that ImageMagick be installed and able to be accessed as an object.

Source

// This script will convert any image into a square 512x512 JPEG for use as folder art for a music file.
// You must have ImageMagick installed and able to be created as an object to run this script.
// © Copyright: Dean Tersigni, 2017-07-05.

var sFile = "";
var oArguments = WScript.Arguments;

if(oArguments.Length > 0) {
	var sFile = oArguments.Item(0);
	
	var oFSO = new ActiveXObject("Scripting.FileSystemObject");
	if(oFSO.FileExists(sFile) == true) {
		var sPath = oFSO.GetParentFolderName(sFile);
		var sName = oFSO.GetBaseName(sFile);
		var sOutput = sPath + "\\folder.jpg";
		
		// Convert image into a square JPEG via ImageMagick.
		var oIM = new ActiveXObject("ImageMagickObject.MagickImage.1");
		oIM.convert(sFile, 
			"-resize", "512x512",
			"-size", "512x512",
			"-gravity", "center",
			"-density", "300x300", "-units", "pixelsperinch",
			"-quality", "100%",
			sOutput);
	} else {
		WScript.Echo("File: " + sFile + " does not exist.");
	}
} else {
	WScript.Echo("Either drop an image file onto this script or run it with an argument of an image file.");
}