Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Non Destructive Trim, protect the layer below

Contributor ,
Apr 22, 2016 Apr 22, 2016

I am trying to script this. I want to be able to trim a layer, then expand the canvas by a set amount. Then reveal the 'whole layer' below. I can do all of this, but the issue I have is I need to trim a layer, but keep the deleted pixels of the layer underneath.

My method prior to using trim is to hide the other layers then 'trim'

Un hiding the layer then use reveal doesn't work as it has been deleted during  trim How can I lock a layer so that this is protected?

Matt

TOPICS
Actions and scripting
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 28, 2016 Apr 28, 2016
LATEST

The script you posted went around copping the document over and over again  without deleting cropped pixels and never saved  out an image.

Your sample one image PSD look like  some one tried  trim the Main Image layer using the magic wand.  They should have set the magic wand mode to contiguous so none of the object interior pixel that may match the colors being trimmed would not be deleted and the magic wand tolerance should have been set higher so the layer would  be trimmed closer to the product object.

He is the script I wrote to trim layers usig the magic wand.  Note all layers can not be trimed. Text layer do not need to te trimmed. Smart ojbect layers pixels can not be changed. Adjustment layers do not have pixels.

http://www.mouseprints.net/old/dpr/TrimLayers.jsx

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 22, 2016 Apr 22, 2016

I think you could come close to scripting a layer trim. The way Photoshop "Trim"  works  thought trims the boundaries transparence or a boundary selected color around an object its a document crop that applies to all the layers in the document.  I do not think  this is what you want.  You do not want to crop the document  and it makes no sense to trim a layer outer border transparency.  IMO the only thing the makes sense is tinning a layers border color that is around a object.

The Problem is a layer can be any shape.  You can get the layers bounds but you can not be sure that a point like the top left corner will have a color pixel or be empty..   You may be able to program a loop with a  try catch  where you try sampling a point like top left corner with the magic wand.  if the magic wand fails to select pixels the catch would change the sample point.  When the magic wand is successful the script would clear the selection trimming the layer boundary color about a subject and break out of the magic wand forever loop and the script would end.

Edit 4/24/2016

I tried but there is a Problem with my Magic Wand idea.  The Magic wand will not fail if the sample area is empty.  It will select all the contiguous empty area.  So my Try Catch ideal was bad guess. All I can up with was to sample 8 points about the layer'e bounds. Eight shots in the dark.

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines