Access Layer Mask in PSD?

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
HawaiiDev
Posts: 3
Joined: 2011-03-12T12:31:02-07:00
Authentication code: 8675308

Access Layer Mask in PSD?

Post by HawaiiDev »

Is it possible to access and change a layer mask color in a PSD file via IM?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Access Layer Mask in PSD?

Post by fmw42 »

might be, but post a link to an example image and explain exactly what you want to do.
HawaiiDev
Posts: 3
Joined: 2011-03-12T12:31:02-07:00
Authentication code: 8675308

Re: Access Layer Mask in PSD?

Post by HawaiiDev »

Sorry for the delay. I have posted a test image here:

http://worldtravelandtours.com/garrett/string-test.psd

It’s a PSD but we can use whatever format, so long as we can accomplish the goal. All we need to do is be able to color each of the strings individually. For example, if we want the first string to be red, we present a palette, choose red and the string is now red. If we want the second string blue, same thing. Present a palette, click on blue and the string is now that shade of blue.

That's really all we need. Just to be able to "color" a certain area of the picture.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Access Layer Mask in PSD?

Post by fmw42 »

This seems to work (note layers are numbered from 0):

First line: read image -- 3 layers, first (0) is flattened layer, next two are separate strings
Second line: clone the first string layer (1), convert to grayscale and then recolor with red
Third line: create a new flattened layer from the modified first string layer and the second string layer
Fourth line: delete the original flattened layer (0) and the original first string layer (1)
Fifth line: reverse the remaining layers to get back to the correct order as in your original image
Sixth line: create new output

convert string-test.psd \
\( -clone 1 -colorspace gray +level-colors black,red \) \
\( -clone 3 -clone 2 -background none -layers merge \) \
-delete 0,1 \
-reverse \
string_test2.psd


http://www.fmwconcepts.com/misc_tests/string_test2.psd
HawaiiDev
Posts: 3
Joined: 2011-03-12T12:31:02-07:00
Authentication code: 8675308

Re: Access Layer Mask in PSD?

Post by HawaiiDev »

Thanks for the response...

I was able to download your finished psd, but when I ran it on my local server I could not open the produced PSD in photoshop to verify?
I get an error of "Could not complete your request because the file is not compatible with this version of Photoshop." Any idea on this error?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Access Layer Mask in PSD?

Post by fmw42 »

It opens fine for me in my old PS CS on my Mac OSX Tiger. It also opens fine in Mac PREVIEW and GIMP. Perhaps PS has changed its format some from my version as my version is rather old. Try some other viewers. Perhaps GIMP or something else on your system. You don't say what platform you are on or what version of PS.

Here I have converted it to a single layer png file.


convert string-test.psd \( -clone 1 -colorspace gray +level-colors black,red \) \
-delete 0,1 -reverse -background none -layers merge string_test3.png

Image
Post Reply