Page 1 of 1

Insert image into PSD layer

Posted: 2015-06-01T22:36:08-07:00
by OlgerD
Hi Guys,

Is there a way to insert an image into a layer in an existing PSD file with IM? Ie, I have a PSD file with 3 layers, and want to insert a jpg into the last layer, without touching the other layers?

Cheers!

Re: Insert image into PSD layer

Posted: 2015-06-02T00:52:53-07:00
by snibgo
Something like this should work. Windows BAT syntax. Adjust for Unix.

Code: Select all

convert ^
  in.psd ^
  ( +clone ^
    in.jpg ^
    -composite ^
  ) ^
  +swap +delete ^
  out.psd
This reads all the layers, makes a clone of the last one, composites x.jpg over it, swaps the last two layers, and deletes the last layer.

Re: Insert image into PSD layer

Posted: 2015-06-02T01:44:04-07:00
by OlgerD
Sweet, I'll give that a try tomorrow. Thanks!

Re: Insert image into PSD layer

Posted: 2015-06-02T17:53:12-07:00
by OlgerD
Unfortunately this doesn't quite work. With a 3 layer PSD, it places the image in.jpg onto to topmost layer, instead of the layer I want. I tried using in.psd[1] and even specify the layer name with -label, but none of that worked.
Even if I got it to work as intended, the purpose of this was to leave the other layers as they are, which isn't happening. I had two layers locked in Photoshop, (see another post of mine asking about locking layers) and was hoping this would be another approach to getting layers to stay locked.
IM takes the original PSD, copies all the layers and creates a new PSD. Unfortunately, it doesn't copy layer properties it doesn't know. Which makes sense I suppose.

snibgo wrote:Something like this should work. Windows BAT syntax. Adjust for Unix.

Code: Select all

convert ^
  in.psd ^
  ( +clone ^
    in.jpg ^
    -composite ^
  ) ^
  +swap +delete ^
  out.psd
This reads all the layers, makes a clone of the last one, composites x.jpg over it, swaps the last two layers, and deletes the last layer.

Re: Insert image into PSD layer

Posted: 2015-06-02T18:40:59-07:00
by fmw42
About locking, see viewtopic.php?f=1&t=27740.

Re: Insert image into PSD layer

Posted: 2015-06-03T00:21:33-07:00
by snibgo
OlgerD wrote:Unfortunately this doesn't quite work. With a 3 layer PSD, it places the image in.jpg onto to topmost layer, instead of the layer I want.
I don't use Photoshop, and don't know what the "topmost" layer is.

In IM, we can clone any of the images in the list with "-clone N". Then do any processing on that new layer. Then "-swap N,-1", then "+delete".

Re: Insert image into PSD layer

Posted: 2015-06-03T01:28:03-07:00
by OlgerD
fmw42 wrote:About locking, see viewtopic.php?f=1&t=27740.
Yeah, thats my other post I was referring to. :-P

Re: Insert image into PSD layer

Posted: 2015-06-03T01:34:32-07:00
by OlgerD
I'm no Photoshop expert either, but I do have access to it at work.
In Photoshop (and I assume this would be true for any app that can open a PSD file), the topmost layer is the highest layer number. Ie, layer 1 is generally the background and in a 3 layer PSD, layer 3 would be the toplayer.
Unfortunately, IM seems to clone only known properties, if any at all.
snibgo wrote:
OlgerD wrote:Unfortunately this doesn't quite work. With a 3 layer PSD, it places the image in.jpg onto to topmost layer, instead of the layer I want.
I don't use Photoshop, and don't know what the "topmost" layer is.

In IM, we can clone any of the images in the list with "-clone N". Then do any processing on that new layer. Then "-swap N,-1", then "+delete".