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?".
Maelcum
Posts: 16
Joined: 2017-12-05T10:42:25-07:00
Authentication code: 1152

Create psd file with a single transparent layer

Post by Maelcum »

Hi guys,

I'm trying to create a Photoshop file: 16 bit, RGB, no alpha channel and just a single transparent layer, but no success.
I've tried a lot of cli settings/options and lately I tried to use a template file (a transparent png file with all the requirements above) and if I resize it and save it as a psd file I'll end up with a grayscale psd file with a black background.
Since I'm just resizing the image I would expect to the operation leaves all the other aspect of the image (channels, transparency, etc) intact but unfortunately it doesn't.

So, my question is, what is the best way to create an empty psd file described above?

Thanks in advance,
M
User avatar
fmw42
Posts: 25562
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 »

I am not sure I understand. Is it a totally transparent image you want to create or an image that has some transparency.

Please always provide your IM version and platform and your exact command line and/or your input image?
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 »

Hi,

Thanks for the quick reply!

IM version: 6.6.3-0
I'd like to create a psd with a single, totally transparent layer.

Thanks in advance,
M
User avatar
fmw42
Posts: 25562
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 »

That version of ImageMagick is over 350 versions old. If it is possible, you would likely need to upgrade. I will try to build one on a current version of ImageMagick and get back to you later today.
User avatar
fmw42
Posts: 25562
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 »

I tried all these commands.

Code: Select all

convert -size 500x500 xc:none -depth 8 PSD:test.psd

convert -size 500x500 xc:none -define tiff:alpha=unassociated tiff:- | convert - test_unassoc.psd
convert -size 500x500 xc:none -define tiff:alpha=associated tiff:- | convert - test_assoc.psd
convert -size 500x500 xc:none -define tiff:alpha=unspecified tiff:- | convert - test_unspec.psd
I tried to load them into Photoshop CS (very old) and they all opened with one transparent layer and one channel labeled gray.

I am not sure what you expect.
User avatar
fmw42
Posts: 25562
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 »

This command should work, but does not.

Code: Select all

convert -size 500x500 xc:none -depth 8 -type truecoloralpha -define colorspace:auto-grayscale=off PSD:test_truecoloralpha.psd
colorspace:auto-grayscale=on|off

prevent automatic conversion to grayscale inside coders that support grayscale. This should be accompanied by -type truecolor. PNG and TIF do not need this define. With PNG, just use PNG24:image. With TIF, just use -type truecolor. JPG and PSD will need this define.

From the changelog:

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 looks like a bug when using PSD. Or possibly the code did not consider transparency.
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 »

Hi,

Thanks for all the suggestions!

Unfortunately, none of them give me the expected result.

As a matter of fact, only the first worked fine (but gave me a grayscale image with a black background and an alpha).
The last one didn't work at all but that's probably because of the old version I'm using.
The rest worked but the generated psd files were invalid, at least CS 2014 wasn't able to open them (the file size is suspiciously small compared to the others, for example the first generated a file ~500 kB, these files around ~60 kB).

Unfortunately, I can't update ImageMagick.

Thanks,
M
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 »

Hi,

I've tried the latest version available on my Mac (using homebrew) and it's still doesn't give me the desired result.

Cheers,
M
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Create psd file with a single transparent layer

Post by dlemstra »

You should use `-set colorspace:auto-grayscale false`. The -define will not set it as a property on the image but -set does. Do you get the correct result with the following command?

Code: Select all

convert -size 500x500 xc:none -depth 8 -set colorspace:auto-grayscale off test.psd
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
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 »

dlemstra wrote: 2017-12-26T11:27:29-07:00 You should use `-set colorspace:auto-grayscale false`. The -define will not set it as a property on the image but -set does. Do you get the correct result with the following command?

Code: Select all

convert -size 500x500 xc:none -depth 8 -set colorspace:auto-grayscale off test.psd
Why is there a difference between -set and -define in this case?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Create psd file with a single transparent layer

Post by dlemstra »

The -define set properties on an internal object called ImageInfo. But the method that makes the image gray only has an Image as input and not an ImageInfo. To set a property on the image itself you will need to use -set instead of -define.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
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 »

dlemstra wrote: 2017-12-26T11:51:12-07:00 The -define set properties on an internal object called ImageInfo. But the method that makes the image gray only has an Image as input and not an ImageInfo. To set a property on the image itself you will need to use -set instead of -define.
But -define has worked before on other images. Why is this different? Is it because it has transparency?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Create psd file with a single transparent layer

Post by dlemstra »

I don't think the `-define` has ever worked on other images. Maybe that format did not try to make the image grayscale? Only some of the encoders will try to do that.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
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 »

From the options page on define:

colorspace:auto-grayscale=on|off

prevent automatic conversion to grayscale inside coders that support grayscale. This should be accompanied by -type truecolor. PNG and TIF do not need this define. With PNG, just use PNG24:image. With TIF, just use -type truecolor. JPG and PSD will need this define.


So according to this, if I want to make a gray JPG or PSD, but have it report colorspace sRGB, then I should do the following. These both work according to identify -verbose, but %[colorspace] is in error.

Code: Select all

convert -size 500x500 xc:gray50 -depth 8 -type truecolor -set colorspace:auto-grayscale off -format "%[colorspace] %[gamma]\n" -write info: test.jpg
sGray 0.454545

identify -verbose test.jpg
Colorspace: sRGB
Type: Grayscale
Gamma: 0.454545

Code: Select all

convert -size 500x500 xc:gray50 -depth 8 -type truecolor -define colorspace:auto-grayscale=off -format "%[colorspace] %[gamma]\n" -write info: test.jpg
sGray 0.454545

identify -verbose test.jpg
Colorspace: sRGB
Type: Grayscale
Gamma: 0.454545
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 »

dlemstra wrote: 2017-12-26T11:27:29-07:00 You should use `-set colorspace:auto-grayscale false`. The -define will not set it as a property on the image but -set does. Do you get the correct result with the following command?

Code: Select all

convert -size 500x500 xc:none -depth 8 -set colorspace:auto-grayscale off test.psd
I've tried this one but it gave me a grayscale image with a transparent layer and an alpha channel.
Then I've changed the command by adding "-type truecolor" (because I need an RGB image) and I got a grayscale image with a background layer and without alpha.

It feels like completely unpredictable when it comes to psd files...

All I wanted is a 16 bit, RGB image with single, transparent layer and no alpha channel.
Seems impossible now.

Cheers,
Imre
Post Reply