Combine two psd files into one, keep filename

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
andrew31
Posts: 4
Joined: 2019-09-12T00:15:10-07:00
Authentication code: 1152

Combine two psd files into one, keep filename

Post by andrew31 » 2019-09-12T00:27:36-07:00

Morning guys, wondering if possible to achieve something like this :

Let's pretend I have these files in the same folder : test-me-1.psd and test-me-5.psd

I want to combine them into a single psd file that would be called as the first file input, so in this case : test-me-1.psd

How I can achieve something like that ?

Filename would change constantly, but not the number.
Working on mac os
Would love to have an option of drag files into a droplet and convert multiple files at the same time.

Any help is appreciated.

snibgo
Posts: 12010
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Combine two psd files into one, keep filename

Post by snibgo » 2019-09-12T06:27:07-07:00

What version of IM? I'll assume v7.

Code: Select all

magick test-me-1.psd test-me-5.psd test-me-1.psd
This reads the two input files, and overwrites the first. Is that what you want?
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 25405
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combine two psd files into one, keep filename

Post by fmw42 » 2019-09-12T10:41:44-07:00

I do not think it is that simple. With PSD files, the first layer is the flattened layer from all the rest. Does the PSD files in this case have multiple layers?. Even if only one layer each, one would need to generate the flattened layer from the two images to add to the two individual layers.

Can the OP explain in more detail the layout of the two PSD files? Or provide examples to use for testing. And explain how the layers of each file need to be combined --- just adding more layers or by some kind of compositing?

Unix does not support drag and drop as far as I know. You would need to have a bash shell script to call imagemagick and then call that bash script from AppleScript to make it drag and drop.

andrew31
Posts: 4
Joined: 2019-09-12T00:15:10-07:00
Authentication code: 1152

Re: Combine two psd files into one, keep filename

Post by andrew31 » 2019-09-12T22:23:57-07:00

snibgo wrote:
2019-09-12T06:27:07-07:00
What version of IM? I'll assume v7.

Code: Select all

magick test-me-1.psd test-me-5.psd test-me-1.psd
This reads the two input files, and overwrites the first. Is that what you want?
It is exactly what I need ! How simple was that ! But there's two small problems:

For some reasons the output file has 2 layers of the test-me-5.psd inside and they are all locked.
And the second problem is how I can run the script on multiple files at once without specifying the names every time ?

Something based on numbers ? Like I said it will always be nr 1.psd and 5.psd

Sorry if asking too much

snibgo
Posts: 12010
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Combine two psd files into one, keep filename

Post by snibgo » 2019-09-13T04:48:09-07:00

andrew31 wrote:For some reasons the output file has 2 layers of the test-me-5.psd inside and they are all locked.
As Fred says, PSD files contain multiple images. The first is a flattened version of all the others. So your two input files contain flattened versions, and these are copied to the output, and an extra flattened version is added.

If you want, you could remove the input flattened images. Windows syntax:

Code: Select all

magick ^
  ( test-me-1.psd -delete 0 ) ^
  ( test-me-5.psd -delete 0 ) ^
  test-me-1.psd
Or bash syntax:

Code: Select all

magick \
  \( test-me-1.psd -delete 0 \) \
  \( test-me-5.psd -delete 0 \) \
  test-me-1.psd
Sorry, I know nothing about locked layers. I don't use Photoshop.

andrew31 wrote:And the second problem is how I can run the script on multiple files at once without specifying the names every time ?
You will need a script. This might find all the files with "1" in the name, and loop through these, running "magick" with each one. If you say what your platform is (eg bash or Windows) we might help more.
snibgo's IM pages: im.snibgo.com

andrew31
Posts: 4
Joined: 2019-09-12T00:15:10-07:00
Authentication code: 1152

Re: Combine two psd files into one, keep filename

Post by andrew31 » 2019-09-13T05:42:41-07:00

Thank you for detailed information !!!

I'm working on MacOSX so bash syntax I guess ?

Thank you !

andrew31
Posts: 4
Joined: 2019-09-12T00:15:10-07:00
Authentication code: 1152

Re: Combine two psd files into one, keep filename

Post by andrew31 » 2019-09-16T01:11:38-07:00

It worked to delete the duplicated layer but the final file is not good. it's just a part of it :(

User avatar
fmw42
Posts: 25405
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combine two psd files into one, keep filename

Post by fmw42 » 2019-09-16T09:14:13-07:00

You need to rebuild the flattened layer from all the other layers after removing the flattened layer from each of the input images.

Code: Select all

magick \
  \( test-me-1.psd -delete 0 \) \
  \( test-me-5.psd -delete 0 \) \
  \( -clone 0--1 \) -insert 0
  test-me-1.psd

Post Reply