code: function (pixmapWidth, pixmapHeight) {
                  // Find out if the mask extends beyond the visible pixels
                  var paddingWanted;
                  ["top", "left", "right", "bottom"].forEach(function (key) {
                      if (paddedInputBounds[key] !== visibleInputBounds[key]) {
                          paddingWanted = true;
                          return false;
                      }
                  });
  
                  // When Photoshop produces inaccurate results, the padding is adjusted to compensate
                  // When no padding is requested, this may be unwanted, so return a padding of 0px
                  if (!paddingWanted) {
                      return { left: 0, top: 0, right: 0, bottom: 0 };
                  }
  
                  var // How much padding is necessary in both dimensions
                      missingWidth  = finalOutputWidth  - pixmapWidth,
                      missingHeight = finalOutputHeight - pixmapHeight,
                      // How of the original padding was on which side (default 0)
                      leftRatio     = paddingInputWidth === 0 ? 0 :
                          ((visibleInputBounds.left - paddedInputBounds.left) / paddingInputWidth),
                      topRatio      = paddingInputHeight === 0 ? 0 :
                          ((visibleInputBounds.top  - paddedInputBounds.top)  / paddingInputHeight),
                      // Concrete padding size on one side so the other side can use the rest
                      leftPadding   = Math.round(leftRatio * missingWidth),
                      topPadding    = Math.round(topRatio  * missingHeight);
  
                  // Padding: how many transparent pixels to add on which side
                  return {
                      left:   Math.max(0, leftPadding),
                      top:    Math.max(0, topPadding),
                      right:  Math.max(0, missingWidth  - leftPadding),
                      bottom: Math.max(0, missingHeight - topPadding)
                  };
              }
docs: The padding depends on the actual size of the returned image, therefore provide a function