Page 1 of 1

Creating Layered PSD with 6K PNGs

Posted: 2016-10-04T12:07:35-07:00
by john.morrison
Hi.

I"m trying to create PSD with 3 6k PNGs. The sample details are below as well as the call to convert. The layers need to be named. One of the layers is a background which can be anything but right now is a solid white background.

I have two problems with the command call. First, I can't get the background image to show. It appears in the layer list, however only the checkerboard shows. Second, the size of the created PSD is HUGE compared to GIMP and Photoshop! I'm a programmer not a graphic artist (yes, I'm a trekkie) and there are way too many parameters to try.

I need a command line driven tool to create the PSD. It is going into an AWS environment. I've tried GIMP and now ImageMagick. I would need to build GIMP to get it to work in the destination environment. Imagemagick installed without issue in the same environment.

Here is the command line (doing testing under windows). This has been cobbled together from examples found by Googling:
convert ^
( -label "car" %BASE%\6k\rav4\Rav4.png -background none -layers mosaic ) ^
( -label "shaddow" %BASE%\6k\rav4\Shadow.png -background none -layers mosaic ) ^
( -label "background" %BASE%\6k\rav4\BG.png -layers mosaic ) ^
( -clone 0--1 -layers mosaic ) ^
-reverse %BASE%\6k\rav4\rav4_win_imagemagick.psd

Here is the version of Imagemagick:

Version: ImageMagick 7.0.3-1 Q16 x64 2016-09-20 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

Here are the files involved. The PSDs were created as their name implies:
Name Size Info
BG.png 124 KB (6000 x 3375) RGBA
Shadow.png 2,992 KB (6000 x 3375) RGBA
Rav4.png 28,605 KB (6000 x 3375) RGBA

rav4_win_imagemagick.psd 632,813 KB
rav4_win_photoshop.psd 182,099 KB


Thanks
John Morrison

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-04T12:41:50-07:00
by snibgo
"identify -verbose" on the two psd files might help you on file sizes. For example, perhaps different compression methods were used.

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-04T16:50:31-07:00
by john.morrison
Ok. The "identify -verbose" showed that the psd created by Photoshop was compressed (zip). The png's are compressed (zip).

The one created by imagemagick does not show any compression on any of the layers. So, I added -compress zip to the output. made no difference. Added -compress zip to each of the input clauses, made no difference.

Thoughts? Ideas?

thanks
jbm

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-04T17:16:20-07:00
by fmw42
When using IM to create a psd file, I believe that you have to create the first layer as already flattened from all the rest of the layers, then add the other layers. That can be done in one command line. I do not think IM can add layer names to the output psd file. It can add labels to the meta data of each layer, but I do not think that will show as layer names when you display the PSD file in Photoshop. I believe that the subsequent layers should be in the order of bottom to top.

I suggest that you provide your input images to some place such as dropbox.com and put the URLs here. Then others can test making your PSD file. Also provide your output image and the one created by Photoshop.

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-07T01:28:02-07:00
by dlemstra
Zip compression is not supported yet but it is being worked on by me. You could try adding -compress rle for now.

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-07T16:06:06-07:00
by john.morrison
Thanks dlemstra. compress rle works great.

here is a link to the dropbox that contains the pngs, .cmd, the psd created by photoshop and the one created by the imtest.cmd. you will have to change the file pathing in the script

https://www.dropbox.com/sh/rq0xqyqr0bqq ... amNSa?dl=0

I'm still having trouble creating the third or "background" layer. In this specific case it is a simple white background. However there will be cases where it will be an actual image background. if I need to create two "calls", one for an image background and one that creates the white background layer, thats fine. How do I create a white background layer?

One thing I noticed is that it takes quite a while (6 minutes) to generate the PSD with the script as written. Now I know that there are a lot of variables like machine specs, what was also running, yada, yada, yada. If there are any efficiences that can be made to the command string that would help.

Ultimately this is going to run under an AWS Lambda driven by Python, assuming I can get it to run reliably in under 4 minutes.

Also, please don't use the images for any purpose other than to assist with my problem. Yes, I know I've placed them in a public website and published the link to them on a public forum......

Thank you for any help

John Morrison

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-07T19:39:01-07:00
by fmw42
IM needs the images in the reverse order to PS. That is, the first layer must be the flattened layer. The next layer is your background image. Then successive foreground layers such that the most visible foreground is the last image supplied to IM.

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-10T09:31:08-07:00
by john.morrison
Thanks fmw42.

So the first clause must the "clone"? What would it be making a clone of? Doesn't the -reverse parm accomplish the reversal of the order?
Or is there something other than the clone clause to create the flattened image. Also, why does there need to be a flattened image.

jbm

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-10T09:44:59-07:00
by fmw42
I believe, that PS always has a flattened image for layer 0, though it is not presented in PS. That is how IM gets the flattened image from PS, by reading the layer 0.

Using -reverse will reverse the order of the images in the command line chain. I overlooked that in your command. I see that you have it there. You would need clones or mpr: images to create the flattened layer from all the other layers. So if you list all the layers in foreground to background order, clone them and make the flattened layer at the end, then reverse the order, it should work.

IM cannot create adjustment layers in its output PSD file. You have to do the adjustments and save those as simple images in your chain of processing, if you need those.

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-11T16:17:18-07:00
by john.morrison
Thanks fmw42.

I see the power of imagemagick. Its number of parameters is a little daunting though.

I hate to keep asking "how do I do blah" questions.

using the images from the dropbox I was able to create the psd with a white background. however the whole psd turned into grayscale. I've tracked it down to the white background layer. I've tried creating a white png as well as putting in the parms for a white layer in the background clause, but the psd always becomes grayscale. If I use another image that is not white, some random 6k landscape for example, the psd is not grayscale and is as in color expected.

Here are the parms to create the white png:
convert -size 6000x3375 -type truecolor -background white -compress rle xc:#ffffff png24:white_bg.png

I even tried changing the xc value to fefefe thinking that is was not exactly white.

What am I doing wrong.

thanks
jbm

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-11T17:32:23-07:00
by fmw42
Does it help to do

Code: Select all

convert -size 6000x3375 xc:"#ffffff" -compress rle white_bg.png
This comes out white for me. A solid color will not become 24 bits, but will likely be Depth: 8/1-bit and type bilevel. But that should not affect your other processing.

Using your posted images, prius_lb.png shadow.png and the following code, I get what looks to me to be a proper PSD file on my old PS CS.

Code: Select all

convert prius_lb.png shadow.png \
\( -clone 1,0 -background white -flatten -alpha off \) \
-reverse prius_im.psd
Is this what you want?

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-13T17:09:46-07:00
by john.morrison
Hi fmw42.

That's pretty close. Even though the background of white is mentioned in the clone clause, it didn't show up in the psd.

I'm looking for what is in my16_priuslb_photoshop.psd. Three named layers: background, shadow, vehicle.

My attempts to create it works great except for the vehicle is grey instead of in color: priuslb_win_white_bg_imagemagick.psd. The script for that one is imtest_white_bg.cmd.

They are in the dropbox link from earlier.

Thanks
John Morrison

Re: Creating Layered PSD with 6K PNGs

Posted: 2016-10-13T18:00:51-07:00
by fmw42
Try either of these two. They work for me.

Code: Select all

convert prius_lb.png shadow.png \( -clone 0 -alpha off -fill white -colorize 100% \) \
\( -clone 2,1,0 -background none -flatten -alpha off \) \
-reverse prius_im1.psd

Code: Select all

convert -size 6000x3375 xc:white PNG24:white.png
convert prius_lb.png shadow.png white.png \
\( -clone 2,1,0 -background none -flatten -alpha off \) \
-reverse prius_im2.psd