how can convert a multilayer psd file to single layer psd file?

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
dostajn
Posts: 6
Joined: 2015-09-10T06:12:31-07:00
Authentication code: 1151

how can convert a multilayer psd file to single layer psd file?

Post by dostajn »

I want to convert a multilayer psd file to single layer psd file with linux bash script whitout photoshop, I use this command

Code: Select all

convert DerOpen.psd[0] DerOpent.psd
But I found many changes when compare a single psd file that convert from "DerOpen.psd" by photoshop:

Code: Select all

#identify DerOpent*
DerOpent.psd[0] PSD 5906x2953 5906x2953+0+0 8-bit DirectClass 122.1MB 1.170u 0:01.179
DerOpent.psd[1] PSD 5906x2953 5906x2953+0+0 8-bit DirectClass 122.1MB 1.130u 0:01.140
and single file create with photoshop:

Code: Select all

identify DerClose.psd
DerClose.psd PSD 5906x2953 5906x2953+0+0 8-bit DirectClass 34.79MB 0.620u 0:00.629
The diffrents are size and Number of layers...
there is any way to convert multilayer psd file to single with same output as photoshop?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how can convert a multilayer psd file to single layer psd file?

Post by fmw42 »

What version of IM and what platform? Can you post your input PSD to dropbox.com and put the URL here? Where does DerClose.psd come from? Your convert command line does not show that!
dostajn
Posts: 6
Joined: 2015-09-10T06:12:31-07:00
Authentication code: 1151

Re: how can convert a multilayer psd file to single layer psd file?

Post by dostajn »

thnx for your replay:
I have send my question from work station and now contact from home and have any access to those files.
I send my files to you in saturday . :)
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: how can convert a multilayer psd file to single layer psd file?

Post by 246246 »

I don't understand why layers other than 0 remains, but I can say about the size now.
PSD spec allows Raw Image Data (0) in image data section, and IM create that one, whereas Photoshop create compressed one. (Someone can check that after you post the image.)

And you stated DerClose.psd is created with Photoshop not with iM, so it is better to write your Photoshop version and how to operate.
dostajn
Posts: 6
Joined: 2015-09-10T06:12:31-07:00
Authentication code: 1151

Re: how can convert a multilayer psd file to single layer psd file?

Post by dostajn »

hi
I apologize,I have a mistake about the DerOpent file. This file made By another program.(please forget .. :) )
for better distinguish my idea, please view two image bellow:
we have a admin operator to get open layer file from designer and close that file and send to print server,so save open layer file in backup server for next usage:
https://www.dropbox.com/s/8avq54dhmjws5 ... m.jpg?dl=0

I want create a script to remove admin roll:
Designer send both open/close file to automation server(base on linux).
server convert open layers file to close file by IM and check two files with md5sum in linux server.if same, send files to printer/backup servers.
https://www.dropbox.com/s/i5iyvcon7kgbf ... m.jpg?dl=0

photoshop version is cs5
I use IM version:

Code: Select all

Version: ImageMagick 6.7.7-10 2014-03-08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP  
this output of identify command:

Code: Select all

openlayer.psd[0] PSD 640x480 640x480+0+0 8-bit DirectClass 107KB 0.010u 0:00.019
openlayer.psd[1] PSD 640x480 640x480+0+0 8-bit DirectClass 107KB 0.010u 0:00.019
openlayer.psd[2] PSD 119x207 119x207+212+93 8-bit DirectClass 107KB 0.010u 0:00.019
openlayer.psd[3] PSD 173x149 173x149+397+263 8-bit DirectClass 107KB 0.010u 0:00.019
openlayer.psd[4] PSD 60x189 60x189+133+68 8-bit DirectClass 107KB 0.010u 0:00.019

close_layer_by_photoshop.tif TIFF 640x480 640x480+0+0 8-bit DirectClass 948KB 0.000u 0:00.000

close_layer_by_IM.tif TIFF 640x480 640x480+0+0 8-bit DirectClass 151KB 0.000u 0:00.000
this is output of md5sum:

Code: Select all

090cf9cedd752ec6b22556ab28a8746e  close_layer_by_IM.tif
2db3887249054c63bcb394b3b58ecd90  close_layer_by_photoshop.tif
this example files are :
https://www.dropbox.com/s/3l1cnkkex6okpb5/out.rar?dl=0
Last edited by dostajn on 2015-09-11T22:28:56-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how can convert a multilayer psd file to single layer psd file?

Post by fmw42 »

Both your tif images look the same. Using IM compare to look at pixel differences, I get zero difference

Code: Select all

compare -metric rmse close_layer_by_IM.tif close_layer_by_photoshop.tif null:
0 (0)

So what is the problem?

By the way, IM 6.7.7-10 is very old (about 140 versions old). You should probably upgrade if you can.

The difference is likely in the compression and meta data. IM is likely doing a some lossless compression and PS is likely doing compression none. So try

Code: Select all

convert openlayer.psd[0] -compress none result.tif
identify result.tif
result.tif TIFF 640x480 640x480+0+0 8-bit sRGB 963KB 0.000u 0:00.000

Or you can change the PS compression to match your IM compression.


You can use tiffinfo to see the meta data differences.

Code: Select all

tiffinfo close_layer_by_IM.tif
tiffinfo close_layer_by_photoshop.tif
tiffinfo shows

close_layer_by_IM.tif
Compression Scheme: PackBits

and

close_layer_by_photoshop.tif
Compression Scheme: None



I am not sure how you achieved PackBits compression, since it is not in the current list of compressions that IM can do. See http://www.imagemagick.org/script/comma ... p#compress. But that may be due to your older IM version. Packbits is an old Apple RLE compression method according to https://en.wikipedia.org/wiki/PackBits. On my Mac OSX system, the listed IM 6.9.2.0 Q16 compressions are:

Code: Select all

convert -list compress
B44
B44A
BZip
DXT1
DXT3
DXT5
Fax
Group4
JBIG1
JBIG2
JPEG
JPEG2000
Lossless
LosslessJPEG
LZMA
LZW
None
Piz
Pxr24
RLE
Zip
RunlengthEncoded
ZipS
And PackBits is not listed, though RLE is. Perhaps PackBits is deprecated in favor of current RLE compression in current IM.
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: how can convert a multilayer psd file to single layer psd file?

Post by 246246 »

First, I have to say it is impossible to create exactly the same file between from Photoshop and from ImageMagick.
Recent Photoshop (after CC) seems to have a feature to run like a service and client can operate for some command from JavaScript. But even if your conversion can be achieved, md5sum would not match because there are some metadata related on creation time etc.

So I think you need to compare image only, using compare command with ImageMagick. If this suggestion does match your demand, it is worth to think about conversion part.
dostajn
Posts: 6
Joined: 2015-09-10T06:12:31-07:00
Authentication code: 1151

Re: how can convert a multilayer psd file to single layer psd file?

Post by dostajn »

fmw42 wrote:Both your tif images look the same. Using IM compare, I get zero difference

Code: Select all

compare -metric rmse close_layer_by_IM.tif close_layer_by_photoshop.tif null:
0 (0)

So what is the problem?

By the way, IM 6.7.7-10 is very old (about 140 versions old). You should probably upgrade if you can.
:roll: :-o :shock:
I need to sure the file created by photoshop is same as the file create by IM:
thus I use "Md5sum"! if "compare" command can tell me two file is same or not same, my problem is solved ...
my problem in automation server is:
Maybe a Designer send to server a different close-open layers and my server lose original open layers file
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how can convert a multilayer psd file to single layer psd file?

Post by fmw42 »

I know little about Md5 check sums. But I would think that any difference might be associated simply with meta data, which may not be significant.

The pixel data is identical. So the images should be the same. Though you may want to be sure that the icc or icm profiles are the same for the sake of printing.

I would also suggest as I mentioned above that you make the IM compression the same as your PSD compression, which in this case seems to be none. Nevertheless, if the compressions are different, but lossless, then it won't make any difference, except for file size, since they will be uncompressed before processing.

See my edits to my post above about the compressions and how to achieve the same compression of none in IM.
dostajn
Posts: 6
Joined: 2015-09-10T06:12:31-07:00
Authentication code: 1151

Re: how can convert a multilayer psd file to single layer psd file?

Post by dostajn »

Thanks for your replay!
my list of compression list is:

Code: Select all

convert -list compress
B44
B44A
BZip
DXT1
DXT3
DXT5
Fax
Group4
JBIG1
JBIG2
JPEG
JPEG2000
Lossless
LosslessJPEG
LZMA
LZW
None
Piz
Pxr24
RLE
Zip
RunlengthEncoded
ZipS

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

Re: how can convert a multilayer psd file to single layer psd file?

Post by fmw42 »

I see no PackBits. So how did your IM TIFF image get that compression? What command did you use to create it? Try -compress none and you should have nearly the same file size as your PSD conversion to TIFF. Or use one of the other PSD lossless compressions and the corresponding one in IM.
dostajn
Posts: 6
Joined: 2015-09-10T06:12:31-07:00
Authentication code: 1151

Re: how can convert a multilayer psd file to single layer psd file?

Post by dostajn »

When convert by this syntex:

Code: Select all

 convert openlayer.psd[0]  close_layer_by_IM.tif
have a PackBits!
if i use:

Code: Select all

 convert openlayer.psd[0] -compress none close_layer_by_IM.tif
all is ok.
I am updating my testing server, maybe this problem is solve in new version's.
Post Reply