How to create a layered PSD file from command line?

后端 未结 6 862
轻奢々
轻奢々 2020-12-04 16:06

I need to create a layered PSD file with ImageMagick or any other command-line tool available on Linux platform. Since I need to do this on Linux server, I

6条回答
  •  春和景丽
    2020-12-04 16:40

    I use the command lines below. I have not encountered any issue in opening the generated PSD in Photoshop, however every layer appears as a background layer, and you have to convert it into a true layer first in order to edit the layer ordering.

    Here is the command line for Window. Given the list of images (im1.xxx, im2.xxx etc, im1 being the bottom layer,) a list of labels for the layers ("label1", "label2"...) :

    convert ^ ( ^ -page +0+0 ^ -label "label1" ^ im1.xxx[0] ^ -background none ^ -mosaic ^ -set colorspace RGB ^ ) ^ ( ^ -page +0+0 ^ -label "label2" ^ "im2.xxx"[0] ^ -background none ^ -mosaic ^ -set colorspace RGB ^ ) ^ ( ^ -clone 0--1 ^ -background none ^ -mosaic ^ ) ^ -alpha Off ^ -reverse ^ "out.psd"

    That is, for each layer, you have something like

    ( ^ -page +0+0 ^ -label "optional_label" ^ im1.xxx[0] ^ -background none ^ -mosaic ^ -set colorspace RGB ^ )

    The label/name of the layer is optional (remove -label if none.) The [0] in im1.xxx[0] retrieves the first image in the image file, in case there exist a thumbnail in the Exif.

    On Unix/OSX, you have to protect the parenthesis by a backslash, and the line continuation characters change also to \:

    \( \ -page +0+0 \ -label "optional_label" \ im1.xxx[0] \ -background none \ -mosaic \ -set colorspace RGB \ \)

    If the image names contain special chars, you can protect them with " (eg "c:\my im1.png") without any issue.

提交回复
热议问题