Auto-crop maintaining square canvas?
Posted: 2008-01-11T02:41:05-07:00
Hi
The -trim operator works well on my transparent-background PNG.
convert foo.png -trim bar.png.
Magick, indeed...
What I'm stuck on is maintaining a square canvas. That is to say, without resorting to scripting such as PerlMagick, I'd like the final image to have a square transparent canvas. FYI, the input image (foo.png) always has a square canvas and the output canvas could be anything, just smaller and almost always not square aspect ratio.
What I'd like to do is have the output image centred in a square, transparent canvas that's got the same pixel dimensions as the longest side (be it x or y) that is the result of the original trim.
I think it's got something to do with making a new, square transparent canvas that's got dimensions of the longest side of bar.png and then compositing bar.png onto that new canvas with a centre gravity. My problem is, without scripting, is how to make that new, square, transparent canvas to accommodate bar.png?
Thanks in advance.
Marcus
The -trim operator works well on my transparent-background PNG.
convert foo.png -trim bar.png.
Magick, indeed...
What I'm stuck on is maintaining a square canvas. That is to say, without resorting to scripting such as PerlMagick, I'd like the final image to have a square transparent canvas. FYI, the input image (foo.png) always has a square canvas and the output canvas could be anything, just smaller and almost always not square aspect ratio.
What I'd like to do is have the output image centred in a square, transparent canvas that's got the same pixel dimensions as the longest side (be it x or y) that is the result of the original trim.
I think it's got something to do with making a new, square transparent canvas that's got dimensions of the longest side of bar.png and then compositing bar.png onto that new canvas with a centre gravity. My problem is, without scripting, is how to make that new, square, transparent canvas to accommodate bar.png?
Thanks in advance.
Marcus