Search code examples
imagemagickoverlappingimagemagick-montage

For Imagemagick, how can I stop the "montage -tile 3x3" command from cropping the output?


I take an image and chop it into 9 equally size tiles. Each tile is run through a process that increases it's resolution. All 9 tiles slightly overlap each other based on a specific hard-coded value.

The issue however is that when the modified tiles are put back together into the original image. ImageMagick seems to crop the new output made of the modified tiles. All the tiles appear to be perfectly positioned, and thus I can't figure out why ImageMagick crops the final output, let alone how I can stop it.

This is the original image before it's chopped into 3x3 overlapping tiles:

https://i.sstatic.net/041hc.jpg

This is the final output composed of the modified tiles:

https://i.sstatic.net/lOTHC.jpg

How can I prevent ImageMagick from cropping this output?

The code used to put the modified tiles back together, is shown below:

# 6. merge feathered tiles
    montage $feathered_dir/$clean_name'_0.png' $feathered_dir/$clean_name'_1.png' \
                    $feathered_dir/$clean_name'_2.png' $feathered_dir/$clean_name'_3.png' \
                    $feathered_dir/$clean_name'_4.png' $feathered_dir/$clean_name'_5.png' \
                    $feathered_dir/$clean_name'_6.png' $feathered_dir/$clean_name'_7.png' \
                    $feathered_dir/$clean_name'_8.png'  -tile 3x3 -geometry -$border_w-$border_h $output/$clean_name.large_feathered.png


    # 7. merge un-feathered tiles
    montage $tiles_dir/$clean_name'_0.png' $tiles_dir/$clean_name'_1.png' \
                    $tiles_dir/$clean_name'_2.png' $tiles_dir/$clean_name'_3.png' \
                    $tiles_dir/$clean_name'_4.png' $tiles_dir/$clean_name'_5.png' \
                    $tiles_dir/$clean_name'_6.png' $tiles_dir/$clean_name'_7.png' \
                    $tiles_dir/$clean_name'_8.png'  -tile 3x3 -geometry -$border_w-$border_h $output/$clean_name.large.png

This command reproduces the same issue:

montage IMG_3926_0.png IMG_3926_1.png IMG_3926_2.png IMG_3926_3.png IMG_3926_4.png IMG_3926_5.png IMG_3926_6.png IMG_3926_7.png IMG_3926_8.png -tile 3x3 -geometry -68.8151-68.8151 out_correct_geometry.png

Edit:

I posted this issue on the ImageMagick forums here: imagemagick.org/discourse-server/viewtopic.php?f=1&t=31221


Solution

  • The solution to the problem can be found here: https://imagemagick.org/discourse-server/viewtopic.php?f=1&t=31221&p=141729