Snibgo, you are right. Thanks for pointing that out. I made a mistake and did not quite understand %@ and %P. I should have tested the following for the second example:
Code: Select all
convert -size 200x100 xc:black -background white -gravity center -extent 300x300 -format "%@\n" info:
200x100+50+100
and
Code: Select all
convert -size 200x100 xc:black -background white -gravity center -extent 300x300 -trim tmp.png
convert tmp.png -format "%P%O\n" info:
300x300+50+100
Code: Select all
convert tmp.png -format "%wx%h\n" info:
200x100
Which are all correct. I was thinking that %P%O should be the same as %@, but the WxH from %@ is the trimmed size and the WxH from %P is the page geometry (virtual canvas).
So my comparison should have been between %@ and %wx%h%O
Code: Select all
convert tmp.png -format "%wx%h%O\n" info:
200x100+50+100
After a +repage, the virtual canvas will be reset, so
Code: Select all
convert tmp.png +repage -format "%P%O\n" info:
0x0+0+0
and
Code: Select all
convert tmp.png +repage -format "%wx%h%O\n" info:
200x100+0+0
So I think I now understand %@ and %P and %wx%h properly
In the trim everything away case, the only proper result seems to be the last one below, even though they all show warnings.
Code: Select all
convert -size 100x100 xc:black -format "%@" info:
convert: geometry does not contain image `' @ warning/attribute.c/GetImageBoundingBox/247.
0x0+100+100
Code: Select all
convert -size 100x100 xc:black -trim -format "%P%O" info:
convert: geometry does not contain image `black' @ warning/attribute.c/GetImageBoundingBox/247.
100x100-1-1
Code: Select all
convert -size 100x100 xc:black -trim -format "%wx%h%O" info:
convert: geometry does not contain image `black' @ warning/attribute.c/GetImageBoundingBox/247.
1x1-1-1
Code: Select all
convert -size 100x100 xc:black -trim +repage -format "%wx%h%O" info:
convert: geometry does not contain image `black' @ warning/attribute.c/GetImageBoundingBox/247.
1x1+0+0
This is confirmed by identify -verbose.
Code: Select all
convert -size 100x100 xc:black -trim +repage tmp.png
identify -verbose tmp.png
Geometry: 1x1+0+0
Histogram:
1: (255,255,255, 0) #FFFFFF00 graya(255,0)
Page geometry: 1x1+0+0
So there seems to be a 1x1 fully transparent white pixel according to identify -verbose.
If I append another image, the result is bigger by 1 pixel.
70x46
Code: Select all
convert tmp.png rose: +append -format "%wx%h\n" info:
71x46
But interestingly, if I extend tmp.png I get an image the size and color of the extent and there is no sign of the single transparent pixel.
Code: Select all
convert tmp.png -background black -extent 100x100 tmp2.png
identify -verbose tmp2.png
Geometry: 100x100+0+0
Histogram:
10000: ( 0, 0, 0) #000000 gray(0)
Page geometry: 100x100+0+0
So I am not really sure what is happening with the trimmed away result.
Is there really a 1x1 pixel image or as you seem to suggest only a null image with a virtual canvas 1x1+0+0.
I think the extent is just recoloring the transparent data, since I can do the following and get a fully black image with no sign of the transparent result.
Code: Select all
convert -size 10x10 xc:"#ffffff00" -alpha on -channel rgba \
-gravity center -background "#000000FF" -extent 30x30 tmp3.png