PSD to PNG conversion(transparent images)

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Houd1ny
Posts: 2
Joined: 2016-10-04T05:27:34-07:00
Authentication code: 1151

PSD to PNG conversion(transparent images)

Post by Houd1ny » 2016-10-04T06:46:35-07:00

Greetings,

Command line tool convert.exe remove transperency from images.
I have seen topic. But it did not help me.
I`m on windows 7 and using Convert.exe from ImageMagick 7.0.3-2 Q16 x64
Issue data:
Original psd
Screenshot of psd made in photoshop
Screenshot of psd made in Libreoffice draw
Saved png using PhotoShop
Png converted using using command convert.exe Opacity2.psd[0] Opacity2_converted.png
Png converted using using command convert.exe -define psd:alpha-unblend=off Opacity2.psd[0] Opacity2_converted_with_unblend_off.png
This psd is generate by my program.
I want to not that opacity is seen in Photoshop but not on Libreoffice draw. Maybe psd is not valid. But from another point of view it is correctly show in Photoshop.
I want that covert.exe return png with transparent images as you could see on "Saved png using PhotoShop".

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

Re: PSD to PNG conversion(transparent images)

Post by fmw42 » 2016-10-04T16:30:30-07:00

According to my old PS CS, your file contains group layers and adjustment layers. My understanding is that Imagemagick will not convert a PSD file with group or adjustment layers to some other format besides just copying to PSD. For that you must be using a very recent version that supports the defines you mention. Unfortunately, IM is limited in its ability to handle such layers. If I have mis-stated, then I defer to the IM developers.

See the -define psd:additional-info=all|selective at http://www.imagemagick.org/script/comma ... php#define

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

Re: PSD to PNG conversion(transparent images)

Post by fmw42 » 2016-10-04T16:39:08-07:00

dlemstra:

Here is another PSD file with group layers that I get an abort trap when using -verbose. IM 6.9.6.0 Q16 Mac OSX. If it does not abort trap for you, then it must be something specific to the IM install (from source) on my Mac.

Code: Select all

identify Opacity2.psd
Opacity2.psd[0] PSD 2048x1024 2048x1024+0+0 8-bit sRGB 51.04MB 0.020u 0:00.019
Opacity2.psd[1] PSD 2048x1024 2048x1024+0+0 8-bit sRGB 51.04MB 0.380u 0:00.390
Opacity2.psd[2] PSD 1024x1024 1024x1024+0+0 8-bit sRGB 51.04MB 0.480u 0:00.490
Opacity2.psd[3] PSD 2049x1024 2049x1024+0+0 8-bit sRGB 51.04MB 0.670u 0:00.680
Opacity2.psd[4] PSD 2048x1024 2048x1024+0+0 8-bit sRGB 51.04MB 0.850u 0:00.870
Opacity2.psd[5] PSD 2048x1024 2048x1024+0+0 8-bit sRGB 51.04MB 1.040u 0:01.050
Opacity2.psd[6] PSD 200x608 200x608+0+0 8-bit sRGB 51.04MB 1.060u 0:01.070
Opacity2.psd[7] PSD 200x302 200x302+0+0 8-bit sRGB 51.04MB 1.070u 0:01.070
Opacity2.psd[8] PSD 300x249 300x249+0+0 8-bit sRGB 51.04MB 1.080u 0:01.080
Opacity2.psd[9] PSD 200x200 200x200+0+0 8-bit sRGB 51.04MB 1.080u 0:01.090
Opacity2.psd[10] PSD 298x559 298x559+0+0 8-bit sRGB 51.04MB 1.110u 0:01.110
Opacity2.psd[11] PSD 200x509 200x509+0+0 8-bit sRGB 51.04MB 1.130u 0:01.130
Opacity2.psd[12] PSD 200x918 200x918+0+0 8-bit sRGB 51.04MB 1.160u 0:01.160
Opacity2.psd[13] PSD 300x878 300x878+0+0 8-bit sRGB 51.04MB 1.200u 0:01.200
Opacity2.psd[14] PSD 200x818 200x818+0+0 8-bit sRGB 51.04MB 1.230u 0:01.230
Opacity2.psd[15] PSD 1224x608 1224x608+0+0 8-bit sRGB 51.04MB 1.290u 0:01.300
Opacity2.psd[16] PSD 1224x302 1224x302+0+0 8-bit sRGB 51.04MB 1.330u 0:01.330
Opacity2.psd[17] PSD 1324x249 1324x249+0+0 8-bit sRGB 51.04MB 1.360u 0:01.360
Opacity2.psd[18] PSD 1224x200 1224x200+0+0 8-bit sRGB 51.04MB 1.380u 0:01.380
Opacity2.psd[19] PSD 1322x559 1322x559+0+0 8-bit sRGB 51.04MB 1.440u 0:01.450
Opacity2.psd[20] PSD 1224x509 1224x509+0+0 8-bit sRGB 51.04MB 1.500u 0:01.500
Opacity2.psd[21] PSD 1224x918 1224x918+0+0 8-bit sRGB 51.04MB 1.600u 0:01.600
Opacity2.psd[22] PSD 1324x878 1324x878+0+0 8-bit sRGB 51.04MB 1.700u 0:01.700
Opacity2.psd[23] PSD 1224x818 1224x818+0+0 8-bit sRGB 51.04MB 1.790u 0:01.790
Opacity2.psd[24] PSD 2048x1024 2048x1024+0+0 8-bit sRGB 51.04MB 1.970u 0:01.970

Code: Select all

identify -verbose Opacity2.psd
Abort trap

Code: Select all

convert Opacity2.psd -define psd:additional-info=all tmp.psd
Abort trap

Code: Select all

convert Opacity2.psd[0] tmp.psd
Abort trap

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

Re: PSD to PNG conversion(transparent images)

Post by fmw42 » 2016-10-04T17:28:32-07:00

P.S. In principle, I believe, you should be able to convert the first layer (the already flattened layer) to some other format. But I am failing with abort trap on that. So I cannot test that hypothesis.

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

Re: PSD to PNG conversion(transparent images)

Post by fmw42 » 2016-11-18T19:11:18-07:00

This seems to work for me on IM 6.9.6.5 Q16 Mac OSX

Code: Select all

convert -limit thread 1 Opacity2.psd[0] tmp.png

On my Mac, I need to disable OpenMP or limit threads to 1 or I get an abort trap.

Houd1ny
Posts: 2
Joined: 2016-10-04T05:27:34-07:00
Authentication code: 1151

Re: PSD to PNG conversion(transparent images)

Post by Houd1ny » 2016-11-21T05:26:24-07:00

fmw42,

Am I correct using IM 6.9.6.5 Q16 on Mac you was able to convert Opacity2.psd to png that It has transparency as on "Saved png using PhotoShop"
I have tested convert from ImageMagick-7.0.3 on MAC and receive the same not transparent png. Could you please confirm that IM 6.9.6.5 produce transparent color rectangles?

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

Re: PSD to PNG conversion(transparent images)

Post by fmw42 » 2016-11-21T10:19:57-07:00

I checked again and you are right. My command does not produce transparent colors. So this is a bug in both IM 6.9.6.5 an 7.0.3.7. I will pass this on to the development team.

User avatar
dlemstra
Posts: 1571
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: PSD to PNG conversion(transparent images)

Post by dlemstra » 2017-06-19T08:37:23-07:00

I found an old e-mail about this topic in my inbox. It appears that the merged image (the first one) does not have the correct pixel values. I don't think we can fix this.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

Post Reply