Make Folder Art

From TheAlmightyGuru
Revision as of 09:37, 3 July 2019 by TheAlmightyGuru (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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


// 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");
			"-resize", "512x512",
			"-size", "512x512",
			"-gravity", "center",
			"-density", "300x300", "-units", "pixelsperinch",
			"-quality", "100%",
	} 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.");