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,WAAY,SACZ,YAAa","file":"/npm/cordova-media-generator@0.4.2/media-gen.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/cordova-media-generator@0.4.2/media-gen.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#! /usr/bin/env node\n\"use strict\";\nvar gm = require('gm'),\n  mkdirp = require('mkdirp'),\n  path = require('path'),\n  fs = require('fs'),\n  config, iOSProjectName,\n  q = require('q');\n\nfunction resize(width, height, bgColour, imagePath, outputFilename, outputPath, strategy) {\n  var deferred = q.defer()\n  gm(path.join(process.cwd(), imagePath)).size(function (error, size) {\n\n    console.log(\"Stategy\", strategy);\n    if (error) {\n      console.error(\"GM Error\", error);\n      deferred.reject(error);\n    } else {\n      // current image size\n      var imageWidth = size.width;\n      var imageHeight = size.height;\n      var ratio = width / height,\n        imageRatio = imageWidth / imageHeight;\n      var image = this;\n\n      // center placement\n      if (ratio >= 1) {\n        //Landscape or square\n        var newWidth = height * imageRatio;\n\n        if (strategy === \"cover\") {\n          if (newWidth <= width) {\n            this.resize(width);\n          } else {\n            this.resize(null, height);\n          }\n        } else {\n          if (newWidth >= width) {\n            this.resize(width);\n          } else {\n            this.resize(null, height);\n          }\n        }\n      } else {\n        var newHeight = width / imageRatio;\n\n        if (strategy === \"cover\") {\n          if (newHeight <= height) {\n            this.resize(null, height);\n          } else {\n            this.resize(width);\n          }\n        } else {\n          if (newHeight >= height) {\n            this.resize(null, height);\n          } else {\n            this.resize(width);\n          }\n        }\n\n      }\n\n      // var x = (width / 2) - (imageWidth / 2);\n      // var y = (height / 2) - (imageHeight / 2);\n\n      mkdirp(path.join(process.cwd(), outputPath), function (err) {\n        image.background(bgColour)\n          .gravity('Center')\n          .extent(width, height)\n          .write(path.join(process.cwd(), outputPath, outputFilename), function (error) {\n            if (error) {\n              console.error(\"Write file error\", error);\n              deferred.reject(error);\n            } else {\n              console.log(this.outname);\n              deferred.resolve(this.outname);\n            }\n          });\n      });\n    }\n\n  });\n  return deferred.promise;\n}\n\nfunction generate() {\n  var deferred = q.defer();\n\n  var images = require('./assets.json');\n\n  if (!config) {\n    console.log(\"Please run `mediagen init` first to create a configuration file, edit that and re-run mediagen\");\n    return;\n  }\n\n  if (config.customImages) {\n    config.customImages.forEach(function (item) {\n      images.push(item);\n    });\n  }\n\n  var totalImages = images.length;\n  console.log(\"------------------------------\");\n  console.log(\"   cordova-media-generator\");\n  console.log(\"------------------------------\");\n  console.log(\"Generating \" + totalImages + \" images so you don't have to!\");\n  console.log(\"------------------------------\");\n\n  images.forEach(function (image) {\n    var background, sourceImage, strategy;\n\n    if (image.source) {\n      sourceImage = image.source.filename;\n      background = image.source.background;\n    } else {\n      if (image.path.indexOf(\"screen\") === -1) {\n        sourceImage = config.icon.filename;\n        background = config.icon.background;\n        strategy = config.icon.strategy;\n      } else {\n        sourceImage = config.splash.filename;\n        background = config.splash.background;\n        strategy = config.splash.strategy;\n      }\n    }\n    if (sourceImage)\n      resize(image.width, image.height, '#' + background, sourceImage, image.filename, image.path, strategy);\n  });\n  deferred.resolve();\n  return deferred.promise;\n}\n\nfunction genConfig() {\n  var deferred = q.defer();\n  var destFile = path.join(process.cwd(), \"mediagen-config.json\");\n\n  fs.writeFile(destFile, JSON.stringify({\n    \"icon\": {\"filename\": \"icon.png\", \"background\": \"fff\", stategy: \"contain\"},\n    \"splash\": {\"filename\": \"splash.png\", \"background\": \"fff\", stategy: \"contain\"},\n    \"customImages\": [\n      {\n        \"width\": 120,\n        \"height\": 120,\n        \"path\": \"res/custom\",\n        \"filename\": \"outputFilename.png\",\n        \"source\": {\"filename\": \"image.png\", \"background\": \"fff\"}\n      }\n    ]\n  }, null, 4), function (err) {\n    deferred.resolve(\"success\");\n  });\n  console.log(\"Created `mediagen-config.json` file in the current directory.\");\n  return deferred.promise;\n}\n\ntry {\n  config = require(process.cwd() + \"/mediagen-config\");\n} catch (e) {\n  if (process.argv[2] !== \"init\") {\n    console.log(\"Could not find configuration file. To create one run `$ mediagen init`\");\n  }\n}\n\nswitch (process.argv[2]) {\n  case \"init\":\n    genConfig();\n    break;\n  default:\n    generate();\n}\n\nmodule.exports = {\n  __resize: resize,\n  __generate: generate,\n  __genConfig: genConfig\n};"]}