Skip to content

Commit

Permalink
Merge branch 'master' into ps-next
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Wehrman committed Apr 22, 2014
2 parents 8869ddb + 2ac96e1 commit ccc8a0f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 24 deletions.
56 changes: 32 additions & 24 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,29 +623,35 @@
* is specified in document coordinates and should encompass the whole layer.
* The output rectangle should be of the target size.
*
* @params {!integer} documentId Document ID
* @params {!integer} layerId Layer ID
* @params {!Object} settings An object with params to request the pixmap
* @params {?boolean} settings.boundsOnly Whether to return an object with bounds rather than the pixmap. The
* returned object will have the format (but with different numbers):
* { bounds: {top: 0, left: 0, bottom: 100, right: 100 } }
* @params {?Object} settings.inputRect Rectangular part of the document to use (usually the layer's bounds)
* @params {?Object} settings.outputRect Rectangle into which the the layer should fit
* @params {?float} settings.scaleX The factor by which to scale the image horizontally (1.0 for 100%)
* @params {?float} settings.scaleX The factor by which to scale the image vertically (1.0 for 100%)
* @params {!float} settings.inputRect.left Pixel distance of the rect's left side from the doc's left side
* @params {!float} settings.inputRect.top Pixel distance of the rect's top from the doc's top
* @params {!float} settings.inputRect.right Pixel distance of the rect's right side from the doc's left side
* @params {!float} settings.inputRect.bottom Pixel distance of the rect's bottom from the doc's top
* @params {!float} settings.outputRect.left Pixel distance of the rect's left side from the doc's left side
* @params {!float} settings.outputRect.top Pixel distance of the rect's top from the doc's top
* @params {!float} settings.outputRect.right Pixel distance of the rect's right side from the doc's left side
* @params {!float} settings.outputRect.bottom Pixel distance of the rect's bottom from the doc's top
* @params {?boolean} settings.useSmartScaling Use Photoshop's "smart" scaling to scale layer, which
* (confusingly) means that stroke effects (e.g. rounded
* rect corners) are *not* scaled. (Default: false)
* @params {?boolean} settings.includeAncestorMasks Cause exported layer to be clipped by any ancestor masks
* that are visible (Default: false)
* @param {!integer} documentId Document ID
* @param {!integer} layerId Layer ID
* @param {!Object} settings An object with params to request the pixmap
* @param {?boolean} settings.boundsOnly Whether to return an object with bounds rather than the pixmap. The
* returned object will have the format (but with different numbers):
* { bounds: {top: 0, left: 0, bottom: 100, right: 100 } }
* @param {?Object} settings.inputRect Rectangular part of the document to use (usually the layer's bounds)
* @param {?Object} settings.outputRect Rectangle into which the the layer should fit
* @param {?float} settings.scaleX The factor by which to scale the image horizontally (1.0 for 100%)
* @param {?float} settings.scaleX The factor by which to scale the image vertically (1.0 for 100%)
* @param {!float} settings.inputRect.left Pixel distance of the rect's left side from the doc's left side
* @param {!float} settings.inputRect.top Pixel distance of the rect's top from the doc's top
* @param {!float} settings.inputRect.right Pixel distance of the rect's right side from the doc's left side
* @param {!float} settings.inputRect.bottom Pixel distance of the rect's bottom from the doc's top
* @param {!float} settings.outputRect.left Pixel distance of the rect's left side from the doc's left side
* @param {!float} settings.outputRect.top Pixel distance of the rect's top from the doc's top
* @param {!float} settings.outputRect.right Pixel distance of the rect's right side from the doc's left side
* @param {!float} settings.outputRect.bottom Pixel distance of the rect's bottom from the doc's top
* @param {?boolean} settings.useSmartScaling Use Photoshop's "smart" scaling to scale layer, which
* (confusingly) means that stroke effects (e.g. rounded rect corners) are *not* scaled. (Default: false)
* @param {?boolean} settings.includeAncestorMasks Cause exported layer to be clipped by any ancestor masks
* that are visible (Default: false)
* @param {?boolean} settings.allowDither controls whether any dithering could possibly happen in the color
* conversion to 8-bit RGB. If false, then dithering will definitely not occur, regardless of either
* the value of useColorSettingsDither and the color settings in Photoshop. (Default: false)
* @param {?boolean} settings.useColorSettingsDither If settings.allowDither is true, then this controls
* whether to (if true) defer to the user's color settings in PS, or (if false) to force dither in any
* case where a conversion to 8-bit RGB would otherwise be lossy. If allowDither is false, then the
* value of this parameter is ignored. (Default: false)
*/
Generator.prototype.getPixmap = function (documentId, layerId, settings) {
if (arguments.length !== 3) {
Expand All @@ -667,7 +673,9 @@
bounds: true,
boundsOnly: settings.boundsOnly,
useSmartScaling: settings.useSmartScaling || false,
includeAncestorMasks: settings.includeAncestorMasks || false
includeAncestorMasks: settings.includeAncestorMasks || false,
allowDither: settings.allowDither || false,
useColorSettingsDither: settings.useColorSettingsDither || false
};

// Because of PS communication irregularities in different versions of PS, it's very complicated to
Expand Down
14 changes: 14 additions & 0 deletions lib/jsx/getLayerPixmap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
// means that stroke effects (e.g. rounded rect corners) are *not* scaled. (Default: false)
// - includeAncestorMasks: setting to "true" causes exported layer to be clipped by any ancestor
// masks that are visible (Default: false)
// - allowDither: controls whether any dithering could possibly happen in the color conversion
// to 8-bit RGB. If false, then dithering will definitely not occur, regardless of either
// the value of useColorSettingsDither and the color settings in Photoshop. (Default: false)
// - useColorSettingsDither: If allowDither is true, then this controls whether to (if true) defer to
// the user's color settings in PS, or (if false) to force dither in any case where a
// conversion to 8-bit RGB would otherwise be lossy. If allowDither is false, then the
// value of this parameter is ignored. (Default: false)

var MAX_DIMENSION = 10000;

Expand Down Expand Up @@ -109,6 +116,13 @@ actionDescriptor.putEnumerated(
stringIDToTypeID("includeVisible")
);

// NOTE: on the PS side, allowDither and useColorSettingsDither default to "true" if they are
// not set at all. However, in Generator, the common case will be that we do NOT want to dither,
// regardless of the settings in PS. So, on the Generator side, we default to false (hence the !! on
// the params properties).
actionDescriptor.putBoolean(stringIDToTypeID("allowDither"), !!params.allowDither);
actionDescriptor.putBoolean(stringIDToTypeID("useColorSettingsDither"), !!params.useColorSettingsDither);

if (params.boundsOnly) {
actionDescriptor.putBoolean(stringIDToTypeID("boundsOnly"), params.boundsOnly);
}
Expand Down

0 comments on commit ccc8a0f

Please sign in to comment.