adobe-photoshop / generator-assets

Generator Plug-in for Adobe Photoshop CC that helps users export image assets
MIT License
496 stars 86 forks source link

Clipped asset when there's a larger-than-canvas layer whose bounds depend on opacity #404

Open mcilroyc opened 8 years ago

mcilroyc commented 8 years ago

This bug was originally reported in watson # 4136380 via pre-release user.

See attached test file.
transparent-texture-clipping.zip

Note the "texture" layer is larger than the canvas. If it is >50% opacity, the entire layer will be included in the PS thumbnail pixmap and the resultant exported asset is correct. But at <50% Opacity, the PS thumbnail will have slightly smaller bounds (because it clips to visible pixels, and the some outermost pixels fall of the end of the clif at some opacity level).

The problem does not exist if we are using "exact bounds", but in the commonly-used "approximate bounds" approach, it results in the odd clipping behavior. There is a poorly handled mismatch between the full "expected" bounds vs. the slightly-reduced pixmap bounds actually returned by PS. The result is a file less than the 800x800 document size.

chadrolfs commented 8 years ago

@pineapplespatula, are you about to check in a fix for this?

pineapplespatula commented 8 years ago

this may be addressed by PR #406

mcilroyc commented 8 years ago

I think this is not addressed by 406. One fix for this issue (which I've tested) is to force "exact bounds" for all top-level or document exports.

like:

        if ((!layer && !layerComp) ||
            isInvisible ||
            hasComplexTransform ||
  ....
chadrolfs commented 8 years ago

Here is another case where exported dimensions are not correct due to layer extending beyond canvas bounds: sjshare/Photoshop/Bugfiles/git/generator-assets/404/