Page 1 of 1

How to write multi-layer Photoshop PSD file?

Posted: 2017-06-01T10:40:11-07:00
by valen
ImageMagick++ (7.0.5-7-Q8-x64-dll)
Visual Studio 2015
Windows 10
Adobe Photoshop CS6 & CC 2017

I am reading in a custom formatted image that contains multiple image layers. I can create a Magick::Image object for each layer, and I can call Magick::Image::Write() on each Image object to write out a PSD file. But these PSD files only have one layer, obviously.

I want to be able to collect a bunch of Magick::Image objects and write out 1 PSD file with all those Images as separate layers within.

How can I do this with Magick++? I'm having trouble finding any help on this.

Re: How to write multi-layer Photoshop PSD file?

Posted: 2017-06-01T14:52:50-07:00
by snibgo
For writing multiple images into a single file in Magick++, see http://www.imagemagick.org/Magick++/STL.html

Re: How to write multi-layer Photoshop PSD file?

Posted: 2017-06-01T16:41:58-07:00
by fmw42
Be sure you create a flattened layer for the first layer, plus all your separate layers and write them all to PSD. PSD from ImageMagick must have the flattened layer first.

Re: How to write multi-layer Photoshop PSD file?

Posted: 2017-06-02T13:59:28-07:00
by valen
Thanks. I am now able to create a std::list<Magick::Image> of images. Then I use Magick::writeImages() to create the Photoshop file. But now when I open the PSD in Photoshop, all the layers are locked as a background layer, if you know what I mean. So, for example if I have 5 images that I'm creating 1 PSD out of, the PSD will end up with 5 layers and each of those layers is a "background" layer instead of a regular layer. Is there some special property I'm supposed to set on the individual Magick::Image objects before I call Magick::writeImages() on them?

Re: How to write multi-layer Photoshop PSD file?

Posted: 2017-06-02T14:25:38-07:00
by snibgo
I don't use Photoshop, and don't know the difference between a background layer and regular layer. Sorry.

Re: How to write multi-layer Photoshop PSD file?

Posted: 2017-06-02T14:46:15-07:00
by fmw42
What was your exact command line(s)?

You have to create the flattened layer and save it and then use that and your original layers.

Code: Select all

magick layer1 layer2 ... layer5 -background none -flatten flataenedlayer
magick flattenedlayer layer1 layer2 ... layer5 result.psd
or

Code: Select all

magick layer1 layer2 ... layer5 ( -clone 0--1 -background none -flatten ) +insert result.psd

Re: How to write multi-layer Photoshop PSD file?

Posted: 2017-06-03T19:39:46-07:00
by valen
I am not using a command line to do this. I am using the Magick++ API. I am creating a bunch of Magick::Image objects and then writing them to a PSD. The first image in the list of images is considered my "flattened" layer. The following images are the subsequent layers.

@snibgo
In Photoshop, when you start a new document you get a locked "background" layer to start with. You cannot edit the background layer. There can only be 1 background layer. You have the option to unlock and convert the background layer into a regular editable layer if you choose. There are not supposed to be multiple background layers, like ImageMagick is giving me when I run the Magick::writeImages() function. Magick::writeImages() is creating an unstable Photoshop document by creating multiple background layers. I hope I'm just doing something wrong in my process and someone here can correct me... Surely I'm not the first person to use Magick++ to create a multi-layer PSD.

Re: How to write multi-layer Photoshop PSD file?

Posted: 2018-11-03T13:19:07-07:00
by jb123
Hi, did you ever solve the "all background layers" issue?
I still run into it with Magick.NET