Hi fmw,
fmw42 wrote:
If this is all you need then try (as the mask image is not important)
convert start.png -background none -gravity southwest -extent 512x512 result.png
Sorry, I should have been more clear. The masking is an important part of the procedure, even though in the example images it is barely noticeable (it results in the black border in the top-right corner of start.png being removed).
fmw42 wrote:
Otherwise, you have a number of other problems. First you need to put your input image before your processing commands and use +repage after a crop and specify the background color for -extent
convert mask.png -resize '113%' -crop 512x67+604+17 +repage -gravity SouthWest -extent 512x512 output1.png
Hmm. I've never seen the -repage command before, I'll try that out.
fmw42 wrote:
then I am not sure what you are doing with -channel A -threshold 50% at the end. Any alpha processing should likely be done on the mask image before compositing it as the alpha channel.
If the mask image is needed as you want some parts transparent and some opaque, then I need to understand a bit more what you are trying to do to help further.
Oops. I didn't really need to include the thresholding for the purpose of this example.
If you are interested in knowing why I have that there, the full command I'm using includes several other adjustments to the final image, one of which is a reduction in the number of colors used (-colors 256). Since the starting image is an 8-bit indexed PNG, and the only difference I wanted in the final image was to make some parts of the image completely transparent, I needed to include the color quantization command to make sure the image wasn't expanded up to a 24-bit image. This worked fine by itself in earlier version of IM (6.3.9), but when using the same command on later versions (6.5.1), the resulting color quantization created a number of semi-transparent colors that didn't need to be there. The "-channel A -threshold 50%" was a way I could force the color quantization to only select one transparent pixel.
To give you a better idea of the original problem, my ultimate goal is to select a sub-region of a binary mask image, and use that to specify which regions should be transparent in a second image. Basically I will am starting with some arbitrary rectangular slice (possibly at a higher/lower magnification) of an image of the Sun's outer atmosphere which looks something like this:
If you are interested in what it is, the data comes from the SOHO satellite:
http://sohowww.nascom.nasa.gov/
Previously, the images I was working with already included their own alpha channels which made the task much simpler. In order to save space, however, we have decided to use a single static alpha mask for all images, and simply offset it as necessary.
Hopefully my post makes a little more sense now. I'm going to take a look into the repage param and see if that will help me. Thanks for your suggestion fmw!