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.
Trouble Creating PSD with Layers
Re: Trouble Creating PSD with Layers
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
I think I've go it fixed now. It's hard coded to 0x0 in the source.
Line 2269, coders/psd.c
I modified this to be:
The product:
http://xjguy.com/final.psd (1.6MB)
And the code I used to do this:
Thanks for all the help!
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);
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);
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Trouble Creating PSD with Layers
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
see my post at viewtopic.php?f=3&t=19781
Re: Trouble Creating PSD with Layers
Nope. I segfault when I try to add a white layer.
I must've done something wrong.
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.
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
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.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Trouble Creating PSD with Layers
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.
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/