Page 2 of 2
Re: Trouble Creating PSD with Layers
Posted: 2011-11-06T19:28:10-07:00
by fmw42
This produces the filled out images with the offsets (except for the red error for the white layer), though -flatten may be better for the composite operation, but -mosaic, I believe is needed to do the offsets and fill-outs. You may have a more elegant way to do this all. Please correct my code if so.
convert -size 100x400 xc:none -fill yellow -draw 'rectangle 20,20 80,380' piece-0.tif
convert -size 100x400 xc:none -fill red -draw 'rectangle 20,20 80,380' piece-1.tif
convert -size 100x400 xc:none -fill green -draw 'rectangle 20,20 80,380' piece-2.tif
convert -size 100x400 xc:none -fill blue -draw 'rectangle 20,20 80,380' piece-3.tif
convert -size 100x400 xc:none -fill pink -draw 'rectangle 20,20 80,380' piece-4.tif
convert \
\( -page +410+10 piece-0.tif -background none -mosaic \) \
\( -page +310+10 piece-1.tif -background none -mosaic \) \
\( -page +210+10 piece-2.tif -background none -mosaic \) \
\( -page +110+10 piece-3.tif -background none -mosaic \) \
\( -page +10+10 piece-4.tif -background none -mosaic \) \
\( -size 600x600 xc:white \) \
\( -clone 5 -clone 0 -clone 1 -clone 2 -clone 3 -clone 4 -mosaic \) \
-reverse -crop 600x600+0+0 +repage test4.psd
The issue seems to be that the original poster was trying to get the offsets without filling out the canvas. I have not been able to do that.
Re: Trouble Creating PSD with Layers
Posted: 2011-11-07T14:54:29-07:00
by rlandrum
Yep. Padding the layers so they are aligned is not an option, unfortunately. As mentioned, I looked at the source and think I see the problem. I'm gonna try recompiling with modified source to see if the layers work.
Re: Trouble Creating PSD with Layers
Posted: 2011-11-08T14:17:29-07:00
by rlandrum
I think I've go it fixed now. It's hard coded to 0x0 in the source.
Line 2269, coders/psd.c
Code: Select all
(void) WriteBlobMSBLong(image,0);
(void) WriteBlobMSBLong(image,0);
(void) WriteBlobMSBLong(image,(unsigned int) next_image->rows);
(void) WriteBlobMSBLong(image,(unsigned int) next_image->columns);
I modified this to be:
Code: Select all
/* FIXME This is the top left bottom right */
(void) WriteBlobMSBLong(image,(unsigned int) next_image->page.y);
(void) WriteBlobMSBLong(image,(unsigned int) next_image->page.x);
(void) WriteBlobMSBLong(image,(unsigned int) next_image->page.y+next_image->rows);
(void) WriteBlobMSBLong(image,(unsigned int) next_image->page.x+next_image->columns);
The product:
http://xjguy.com/final.psd (1.6MB)
And the code I used to do this:
Code: Select all
convert -size 100x400 xc:none -fill yellow -draw 'rectangle 20,20 80,380' piece-0.png
convert -size 100x400 xc:none -fill red -draw 'rectangle 20,20 80,380' piece-1.png
convert -size 100x400 xc:none -fill green -draw 'rectangle 20,20 80,380' piece-2.png
convert -size 100x400 xc:none -fill blue -draw 'rectangle 20,20 80,380' piece-3.png
convert -size 100x400 xc:none -fill pink -draw 'rectangle 20,20 80,380' piece-4.png
convert \
\( -repage 100x400+410+10 piece-0.png \) \
\( -repage 100x400+310+10 piece-1.png \) \
\( -repage 100x400+210+10 piece-2.png \) \
\( -repage 100x400+110+10 piece-3.png \) \
\( -repage 100x400+10+10 piece-4.png \) \
\( -clone 0 -clone 1 -clone 2 -clone 3 -clone 4 -background white -mosaic \) \
-reverse final.psd
Thanks for all the help!
Re: Trouble Creating PSD with Layers
Posted: 2011-11-08T16:31:24-07:00
by fmw42
Nice work. But with your new code, if you add a white layer, does it come out white or red?
see my post at
viewtopic.php?f=3&t=19781
Re: Trouble Creating PSD with Layers
Posted: 2011-11-08T18:04:24-07:00
by rlandrum
Nope. I segfault when I try to add a white layer.
I must've done something wrong.
Code: Select all
./bin/convert -size 600x600 -density 400 xc:white -transparent purple bg.png
./bin/convert \
\( -repage 100x400+410+10 piece-0.png -density 400 \) \
\( -repage 100x400+310+10 piece-1.png -density 400 \) \
\( -repage 100x400+210+10 piece-2.png -density 400 \) \
\( -repage 100x400+110+10 piece-3.png -density 400 \) \
\( -repage 100x400+10+10 piece-4.png -density 400 \) \
\( -repage 600x600+0+0 bg.png -density 400 \) \
\( -clone 5 -clone 0 -clone 1 -clone 2 -clone 3 -clone 4 -mosaic \) \
-reverse final.psd
Without bg.png it works. If I copy any of the other pieces, it works. If I overlap or use +0+0, it works. I not sure why it's acting so funny. It is interesting that the final image has no background. Perhaps there's some channel confusion. I'm betting anything with a conflicting background is gonna cause an error....
I tested it. If I change one of my pngs to be white instead of blue, it creates final.psd, but GIMP bombs. If I do convert -size 600x600 xc:white bg.psd, GIMP is fine with it. It's gotta be something in the channels and layers. It also happens with black. No other colors seem to cause the GIMP plugin to segfault.
Upon further testing, I found that adding bg.psd (All white) to my image stack does NOT cause it to segfault, but does introduce some weird rendering artifacts. Not sure what that's all about yet.
Re: Trouble Creating PSD with Layers
Posted: 2011-11-08T18:15:29-07:00
by anthony
Note that all the layet methods flatten, mosaic, merge all should have a background color set. The latter two especially needs it if the image is enlarged beyond the initial canvas.
If no background color is set the color comes from the image meta-data itself. Unless you trace it through, that color could be anything.
set a background color to override the meta-data default.