9
5
Alternatively: How do I take a non-square PNG and "fill out" the "rest" of the image with transparency so that the resulting square image has the original image centered in the square?
ULTIMATELY, what I want is to take any image of any GM-supported format of any size, and create a scaled-down PNG (say, 40 pixels maximum for either dimension), with aspect ratio maintained, transparency-padded for non-square original images, AND with an already-prepared 40x40 PNG transparency mask applied.
I already know how to scale down and keep aspect ratio; I already have the command for applying my composite. My only missing piece is square-alizing non-square images (padding with transparency).
Single command preferred; multi-command chain acceptable.
(edit)
Extra info: Here's the composite command I'm using:
gm composite -compose copyopacity mask.png source-and-target.png source-and-target.png
where mask.png has white pixels for what I want to keep of source-and-target.png and transparent pixels for what I want to remove (and become transparent) of source-and-target.png.
So we can't do it in one shot with
composite
? – Pistos – 2012-04-24T01:23:38.193@Pistos I am not clear on what you are doing with the composite - it is just a transparency mask to hide/show portions of the thumbnail after resizing? Can you [edit] and add the command sequence you have so far, so we can see if it can be combined? – Paul – 2012-04-24T02:47:27.370
@Pistos I think the best approach is to do the compositing with -convert rather than the other way around. I have updated my answer above. – Paul – 2012-04-24T03:33:29.480
Close, but not quite. Your command didn't work as-is, and even with adjustments, it didn't work. It's okay, I'll do it in two steps. I'll update things here after I get the final, working CLI steps. Thanks again. – Pistos – 2012-04-24T03:53:16.660
I would add
-filter Catrom
before thethumbnail
option because from my experience it generally produces higher quality images. – thdoan – 2013-12-04T02:40:37.870