So I take the overlap (crop) value that I used, and try to calculate the new overlap value for use by -smush. But for whatever reason, my code only gets me close the real -smush value, and not the exact -smush value. Any ideas as to why?
I can figure out where I am screwing up the math for the -smush value.
I get the height and width of the tiles I cropped out of my starting image:
Code: Select all
original_tile_w=`convert $out_dir/$clean_name'_0.png' -format "%w" info:`
original_tile_h=`convert $out_dir/$clean_name'_0.png' -format "%h" info:`
All the original tiles are resized so that they are equal in size:
Code: Select all
#Resize all tiles to avoid ImageMagick weirdness
convert $out_dir/$clean_name'_0.png' -resize "$original_tile_w"x"$original_tile_h"\! $out_dir/$clean_name'_0.png'
convert $out_dir/$clean_name'_1.png' -resize "$original_tile_w"x"$original_tile_h"\! $out_dir/$clean_name'_1.png'
convert $out_dir/$clean_name'_2.png' -resize "$original_tile_w"x"$original_tile_h"\! $out_dir/$clean_name'_2.png'
convert $out_dir/$clean_name'_3.png' -resize "$original_tile_w"x"$original_tile_h"\! $out_dir/$clean_name'_3.png'
convert $out_dir/$clean_name'_4.png' -resize "$original_tile_w"x"$original_tile_h"\! $out_dir/$clean_name'_4.png'
convert $out_dir/$clean_name'_5.png' -resize "$original_tile_w"x"$original_tile_h"\! $out_dir/$clean_name'_5.png'
convert $out_dir/$clean_name'_6.png' -resize "$original_tile_w"x"$original_tile_h"\! $out_dir/$clean_name'_6.png'
convert $out_dir/$clean_name'_7.png' -resize "$original_tile_w"x"$original_tile_h"\! $out_dir/$clean_name'_7.png'
convert $out_dir/$clean_name'_8.png' -resize "$original_tile_w"x"$original_tile_h"\! $out_dir/$clean_name'_8.png'
#WxH
I get the height and width of the processed tiles (which should be larger than the original tiles):
Code: Select all
upres_tile_w=`convert $tiles_dir/$clean_name'_0.png' -format "%w" info:`
upres_tile_h=`convert $tiles_dir/$clean_name'_0.png' -format "%h" info:`
I specify the "overlap" value (The value I used to crop the image into tiles) future code to use:
I calculate the difference between the original tiles, and the new tiles for both the height and width:
Code: Select all
tile_diff_w=`echo $upres_tile_w $original_tile_w | awk '{print $1/$2}'`
tile_diff_h=`echo $upres_tile_h $original_tile_h | awk '{print $1/$2}'`
I then calculate how much the overlap should have increased on the processed tiles for both the height and width:
Code: Select all
overlap_diff_w=`echo $overlap_w $tile_diff_w | awk '{print $1*$2}'`
overlap_diff_h=`echo $overlap_h $tile_diff_h | awk '{print $1*$2}'`
Then finally to calculate the -smush value, I add the overlap change to the original overlap value:
Code: Select all
smush_value_w=`echo $overlap_w $overlap_diff_w | awk '{print $1+$2}'`
smush_value_h=`echo $overlap_h $overlap_diff_h | awk '{print $1+$2}'`
But this code does not put the image back together correctly. It looks like it's close-ish to putting the image back together, but I can't figure out my mathematical error.
All the -smush values for when I put the image back together, are made negative like this:
Code: Select all
-smush -$smush_value_w
-smush -$smush_value_h