Create psd file with a single transparent layer

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?".
User avatar
fmw42
Posts: 22954
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create psd file with a single transparent layer

Post by fmw42 » 2017-12-28T16:14:04-07:00

In IM 6.9.9.29 Q16 Mac OSX, I did the following:

Code: Select all

convert -size 400x400 xc:"gray(255,0)" -type grayscalealpha im_transparent.psd
Opening it in GIMP looks just like the image I created in PS Elements. It has white transparency. GIMP complained about the resolution, though I am not sure why, but opened the file.

Bonzo
Posts: 2956
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Create psd file with a single transparent layer

Post by Bonzo » 2017-12-28T16:25:27-07:00

Using your commands I produced the same two images. The first opens in Photoshop CC and looks like a white square; the second says: "This file contains one or more layers that appear to be corrupted. Continue reading layers?"
I then went with flatten and get another error "Could not place "im2_transparent.psd" because an unexpected end-of-file was encountered.

Using magick instead of convert gave the same results.

Maelcum
Posts: 16
Joined: 2017-12-05T10:42:25-07:00
Authentication code: 1152

Re: Create psd file with a single transparent layer

Post by Maelcum » 2017-12-28T17:10:02-07:00

Hi,

Here's the link for 3 psd files and a screenshot showing layer/channel info: https://www.dropbox.com/s/2xkcv00dl10r9 ... t.zip?dl=0

I hope it works.

Cheers,
M

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

Re: Create psd file with a single transparent layer

Post by fmw42 » 2017-12-28T18:35:15-07:00

In IM 6.9.9.29 Q16 Mac OSX, I did the following:

Code: Select all

convert -size 400x400 xc:"gray(255,0)" -depth 16 -type grayscalealpha im_transparent.psd
Opening it in GIMP looks just like the image I created in PS Elements. It has white transparency. GIMP complained about the resolution, though I am not sure why, but opened the file.

Try this while I review your files.

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

Re: Create psd file with a single transparent layer

Post by fmw42 » 2017-12-28T18:51:31-07:00

Your TransparentLayer.PNG file shows that there are R,G,B channels and transparency. So it is not grayscale (1 channel), but is likely grayscale (3 channels), so considered colorspace RGB with equal R,G,B.

Opening your template.psd in GIMP shows R,G,B Alpha channels

Imagemagick shows R=G=B as 16/1-bits per channel and white with a 16/1-bit alpha with value of 0 (fully transparent). That is it is a 16 bit file with only two values 0 and 65535 gray levels.

Code: Select all

identify -verbose template.psd
Image: template.psd
  Format: PSD (Adobe Photoshop bitmap)
  Class: DirectClass
  Geometry: 100x100+0+0
  Resolution: 72x72
  Print size: 1.38889x1.38889
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: Bilevel
  Base type: Undefined
  Endianess: MSB
  Depth: 16/1-bit
  Channel depth:
    red: 1-bit
    green: 1-bit
    blue: 1-bit
    alpha: 1-bit
  Channel statistics:
    Pixels: 10000
    Red:
      min: 65535  (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 8.192e+63
      skewness: 1e+45
      entropy: nan
    Green:
      min: 65535  (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 8.192e+63
      skewness: 1e+45
      entropy: nan
    Blue:
      min: 65535  (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 8.192e+63
      skewness: 1e+45
      entropy: nan
    Alpha:
      min: 0  (0)
      max: 0 (0)
      mean: 0 (0)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: 0
      entropy: nan
  Image statistics:
    Overall:
      min: 0  (0)
      max: 65535 (1)
      mean: 49151.2 (0.75)
      standard deviation: 0 (0)
      kurtosis: -0.666783
      skewness: -1.15466
      entropy: nan
  Alpha: srgba(255,255,255,0)   #FFFFFFFFFFFF0000
  Colors: 1
  Histogram:
     10000: (65535,65535,65535,    0) #FFFFFFFFFFFF0000 srgba(255,255,255,0)
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 100x100+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: None
  Orientation: Undefined
  Properties:
    date:create: 2017-12-28T17:45:23-08:00
    date:modify: 2017-12-28T19:05:58-08:00
    dc:format: application/vnd.adobe.photoshop
    photoshop:ColorMode: 3
    signature: 9e9eb51de1b4128c59d6e66c3a4910bb54dc3799f23d5f72bf9cc4e97d728f1e
    tiff:XResolution: 72
    tiff:YResolution: 72
    xmp:CreateDate: 2017-12-06T14:12:57-05:00
    xmp:CreatorTool: Adobe Photoshop CC 2014 (Windows)
    xmp:MetadataDate: 2017-12-08T15:07:09-05:00
    xmp:ModifyDate: 2017-12-08T15:07:09-05:00
    xmpMM:DocumentID: adobe:docid:photoshop:4f26c4a8-dc53-11e7-9170-e657d102cdc7
    xmpMM:InstanceID: xmp.iid:63f83b28-654c-bb47-923c-e09e1f783d70
    xmpMM:OriginalDocumentID: xmp.did:ba53f78c-4b81-9246-bd0e-33b7819e9b46
  Profiles:
    Profile-8bim: 17870 bytes
    Profile-exif: 306 bytes
    Profile-xmp: 14334 bytes
  Artifacts:
    filename: template.psd
    verbose: true
  Tainted: False
  Filesize: 98390B
  Number pixels: 10000
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.9-29 Q16 x86_64 2017-12-27 http://www.imagemagick.org
This would agree that it is RGB with equal R=G=B=255 (or white) with full transparency by way of alpha=0, ie. rgb(255,255,255,0) colors in a 16-bit file.

To reproduce this in IM, use

Code: Select all

convert -size 400x400 xc:"rgba(255,255,255,0)" -depth 16 -type truecoloralpha -set colorspace:auto-grayscale off im_transparent_rgb_white_alpha.psd

Code: Select all

identify -verbose im_transparent_rgb_white_alpha.psd
Image: im_transparent_rgb_white_alpha.psd
  Format: PSD (Adobe Photoshop bitmap)
  Class: DirectClass
  Geometry: 400x400+0+0
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: Bilevel
  Base type: Undefined
  Endianess: MSB
  Depth: 16/1-bit
  Channel depth:
    red: 1-bit
    green: 1-bit
    blue: 1-bit
    alpha: 1-bit
  Channel statistics:
    Pixels: 160000
    Red:
      min: 65535  (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 8.192e+63
      skewness: 1e+45
      entropy: nan
    Green:
      min: 65535  (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 8.192e+63
      skewness: 1e+45
      entropy: nan
    Blue:
      min: 65535  (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 8.192e+63
      skewness: 1e+45
      entropy: nan
    Alpha:
      min: 0  (0)
      max: 0 (0)
      mean: 0 (0)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: 0
      entropy: nan
  Image statistics:
    Overall:
      min: 0  (0)
      max: 65535 (1)
      mean: 49151.2 (0.75)
      standard deviation: 0 (0)
      kurtosis: -0.666674
      skewness: -1.1547
      entropy: nan
  Alpha: srgba(255,255,255,0)   #FFFFFFFFFFFF0000
  Colors: 1
  Histogram:
    160000: (65535,65535,65535,    0) #FFFFFFFFFFFF0000 srgba(255,255,255,0)
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 400x400+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 0 of 2
  Compression: None
  Orientation: Undefined
  Properties:
    date:create: 2017-12-28T17:57:47-08:00
    date:modify: 2017-12-28T17:57:47-08:00
    signature: 2e767511484a8f057c76a36091d6eb446c3ad433c7c697386189da89a63a6d6b
    tiff:XResolution: 0
    tiff:YResolution: 0
  Profiles:
    Profile-8bim: 28 bytes
  Artifacts:
    filename: im_transparent_rgb_white_alpha.psd
    verbose: true
  Tainted: False
  Filesize: 2.44156MiB
  Number pixels: 160000
  Pixels per second: 16MB
  User time: 0.020u
  Elapsed time: 0:01.009
  Version: ImageMagick 6.9.9-29 Q16 x86_64 2017-12-27 http://www.imagemagick.org
Image: im_transparent_rgb_white_alpha.psd
  Format: PSD (Adobe Photoshop bitmap)
  Class: DirectClass
  Geometry: 400x400+0+0
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: Bilevel
  Base type: Undefined
  Endianess: MSB
  Depth: 16/1-bit
  Channel depth:
    red: 1-bit
    green: 1-bit
    blue: 1-bit
    alpha: 1-bit
  Channel statistics:
    Pixels: 160000
    Red:
      min: 65535  (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 8.192e+63
      skewness: 1e+45
      entropy: nan
    Green:
      min: 65535  (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 8.192e+63
      skewness: 1e+45
      entropy: nan
    Blue:
      min: 65535  (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 8.192e+63
      skewness: 1e+45
      entropy: nan
    Alpha:
      min: 0  (0)
      max: 0 (0)
      mean: 0 (0)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: 0
      entropy: nan
  Image statistics:
    Overall:
      min: 0  (0)
      max: 65535 (1)
      mean: 49151.2 (0.75)
      standard deviation: 0 (0)
      kurtosis: -0.666674
      skewness: -1.1547
      entropy: nan
  Alpha: srgba(255,255,255,0)   #FFFFFFFFFFFF0000
  Colors: 1
  Histogram:
    160000: (65535,65535,65535,    0) #FFFFFFFFFFFF0000 srgba(255,255,255,0)
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 400x400+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 1 of 2
  Compression: None
  Orientation: Undefined
  Properties:
    date:create: 2017-12-28T17:57:47-08:00
    date:modify: 2017-12-28T17:57:47-08:00
    label: L1
    signature: 2e767511484a8f057c76a36091d6eb446c3ad433c7c697386189da89a63a6d6b
    tiff:XResolution: 0
    tiff:YResolution: 0
  Profiles:
    Profile-8bim: 28 bytes
  Artifacts:
    filename: im_transparent_rgb_white_alpha.psd
    psd:layer.opacity: 65535
    psd:layer.x: 0
    psd:layer.y: 0
    verbose: true
  Tainted: False
  Filesize: 2.44156MiB
  Number pixels: 160000
  Pixels per second: 1.33333MB
  User time: 0.440u
  Elapsed time: 0:01.120
  Version: ImageMagick 6.9.9-29 Q16 x86_64 2017-12-27 http://www.imagemagick.org
Fredericks-Mac-mini:desktop fred$ 
Imagemagick shows it as two identical layers. This is because IM created PSD files always are reported by identify -verbose as having two layers, though in Photoshop you should only see one. The first layer is the flattened combinations image of all the other layers, which in this case is the one proper layer, namely, the second layer

But GIMP only shows the one layer same as Photoshop.

Try the above command and see if Photoshop opens it and shows the layers and channels the same as your file.

Maelcum
Posts: 16
Joined: 2017-12-05T10:42:25-07:00
Authentication code: 1152

Re: Create psd file with a single transparent layer

Post by Maelcum » 2017-12-28T19:51:24-07:00

Hi,

I tried it and it produced a grayscale image.

Edit: Opened the generated image in Affinity so I'm not 100% sure about it, although Affinity opened my template.psd just fine.

Cheers,
M

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

Re: Create psd file with a single transparent layer

Post by fmw42 » 2017-12-28T20:13:01-07:00

I do not know Affinity nor what requirements it needs for Photoshop files. But some tools will show it as grayscale simply because the 3 RGB channels are equal. Does it have transparency?

As far as I can tell it looks fine in GIMP and Photoshop Elements.

The question is does it work in your Photoshop?

Maelcum
Posts: 16
Joined: 2017-12-05T10:42:25-07:00
Authentication code: 1152

Re: Create psd file with a single transparent layer

Post by Maelcum » 2017-12-28T20:28:10-07:00

It has transparency but it's grayscale and has alpha.
I'll check it in PS tomorrow.

Cheers,
Imre

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

Re: Create psd file with a single transparent layer

Post by fmw42 » 2017-12-28T21:08:23-07:00

Why does it matter if it is grayscale or RGB with equal channels?

One can always make a colored image with full transparency if you need that.

But I notice I posted the wrong command above and have edited it. Try this one below (same as edited above). It should report RGB even though the channels are equal.

Code: Select all

convert -size 400x400 xc:"rgba(255,255,255,0)" -depth 16 -type truecoloralpha -set colorspace:auto-grayscale off im_transparent_rgb_white_alpha.psd
This requires the following version of Imagemagick or higher:

2015-07-25 6.9.2-0 Dirk Lemstra <dirk@lem.....org>
Added "-set colorspace:auto-grayscale false" that will prevent automatic conversion to grayscale inside coders that support grayscale.

It would seem that your 6.6.3-0 is too old for the -set colorspace:auto-grayscale off. It is close to 400 versions old. Can you upgrade to a higher version of Imagemagick that would be compatible with this newer feature?

Affinity appears to be an Apple product. If so, you should be able to upgrade Imagemagick for Mac using either Homebrew or MacPorts or from the Imagemagick binary page (for the latter only High Sierra).

Maelcum
Posts: 16
Joined: 2017-12-05T10:42:25-07:00
Authentication code: 1152

Re: Create psd file with a single transparent layer

Post by Maelcum » 2017-12-29T07:49:06-07:00

"Why does it matter if it is grayscale or RGB with equal channels?"
Because I need to create an RGB image and not a grayscale one. It's that simple. It's about colour mode an not content.

Unfortunately, I can't update IM in the office so I'm stuck with an old version.

Affinity is not an Apple product, it's created by Serif (http://www.serif.com/) and available for Apple and Windows.
I have the latest IM via Homebrew on my Mac but I don't use PS at home so it's a bit tricky to investigate this issue...

Cheers,
M

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

Re: Create psd file with a single transparent layer

Post by fmw42 » 2017-12-29T10:57:22-07:00

If you want a transparent image that is RGB, then use a color (anything but perfect shades of gray) under the alpha channel. So for example here is a color image that is nearly white

Code: Select all

convert -size 400x400 xc:"rgba(255,255,254,0)" -depth 16 -type truecoloralpha result.psd
or one that is nearly black

Code: Select all

convert -size 400x400 xc:"rgba(1,0,0,0)" -depth 16 -type truecoloralpha result.psd

Maelcum
Posts: 16
Joined: 2017-12-05T10:42:25-07:00
Authentication code: 1152

Re: Create psd file with a single transparent layer

Post by Maelcum » 2017-12-29T12:02:52-07:00

Hi,

These seems to be working fine with newer IM, thanks!

Cheers,
M

Post Reply