set hist to {0, 0, 0, 0, 0, 1, 3, 27, 91, 264, 425, 724, 888, 819, 604, 585, 474, 422, 467, 486, 478, 464, 472, 524, 483, 473, 460, 438, 441, 378, 384, 298, 256, 229, 200, 164, 148, 134, 137, 129, 113, 122, 111, 109, 116, 109, 131, 112, 134, 115, 95, 108, 115, 120, 135, 113, 124, 107, 123, 115, 128, 107, 153, 128, 113, 148, 129, 136, 135, 152, 146, 126, 144, 163, 173, 164, 152, 172, 181, 161, 176, 175, 179, 203, 203, 191, 226, 201, 234, 214, 240, 240, 206, 223, 248, 260, 263, 278, 250, 273, 281, 283, 302, 304, 295, 285, 238, 280, 277, 268, 301, 314, 334, 366, 369, 398, 414, 471, 501, 571, 595, 643, 704, 629, 624, 627, 620, 564, 661, 689, 765, 789, 862, 848, 878, 990, 988, 1037, 1127, 1230, 1354, 1474, 1752, 1973, 1806, 1288, 760, 579, 613, 629, 743, 756, 756, 771, 805, 902, 958, 993, 925, 922, 911, 1000, 1243, 1300, 1405, 1386, 1423, 1217, 662, 418, 239, 148, 122, 116, 115, 119, 94, 90, 89, 79, 69, 81, 57, 81, 43, 61, 47, 65, 48, 44, 46, 40, 40, 55, 39, 44, 34, 41, 44, 56, 45, 33, 33, 33, 40, 28, 28, 30, 23, 27, 20, 22, 14, 15, 9, 7, 8, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
set file_name to "ABC.tif"
set w to 1234 as string
set h to 5678 as string
set his_henkan to hist_gensyoku(hist) --減色値タブ区切り
set file_name to file_name & tab & w & tab & h & tab & his_henkan
--減色ルーチン
on hist_gensyoku(hist)
--0,63,127,91,255
set hist1 to items 1 thru 64 of hist
set hist1 to hist_gokei(hist1) of me
set hist2 to items 65 thru 128 of hist
set hist2 to hist_gokei(hist2) of me
set hist3 to items 129 thru 192 of hist
set hist3 to hist_gokei(hist3) of me
set hist4 to items 193 thru 256 of hist
set hist4 to hist_gokei(hist4) of me
set gensyoku_hist to hist1 & tab & hist2 & tab & hist3 & tab & hist4
end hist_gensyoku
--抽出リスト合計ルーチン
on hist_gokei(a_histrist)
set asdlm to AppleScript's text item delimiters
set AppleScript's text item delimiters to " + "
try
set calcString to (a_histrist as string)
set AppleScript's text item delimiters to asdlm
on error
set AppleScript's text item delimiters to asdlm
return
end try
set gokei to do shell script "echo " & quoted form of calcString & " | bc"
return gokei
end hist_gokei