我正在從FilemakerPro中調用Applescript。 這些都是我儘量做到的事情:AppleScript調整圖像大小並以新名稱保存
- 的圖像存儲在容器字段中。
- 它將其名稱和路徑存儲在單獨的字段中。
一個AppleScript被激活以執行以下操作:
- 它從FilemakerPro檢索數據
- 它檢查是否存在具有相同名稱的字段「calculate_merk_id」 的文件夾
- 如果不是,它會創建文件夾
- 它會創建一個新的圖像文件,該圖像文件的名稱在調整爲155 x 134後應將「__small」添加到其名稱中,並將其存儲在此文件夾中
- 它創建該文件夾中的一個新的鏡像文件應該有其名「__large補充說:」以他的名字已經調整到400×400後,並將其存儲
我收到的第一個錯誤是,它無法檢索圖像的尺寸。此外,它不會創建我調整大小的圖像...任何人想要給我一個正確的方向,請好嗎?
set pad to cell "ServerImagePath" of current record
set filenaam to cell "afbeelding_local_vol_pad" of current record
set foldernaam to cell "calculate_merk_id" of current record
set volle_foldernaam to cell "ServerImageFolder" of current record
set volle_filenaam to cell "ServerImageFile" of current record
set target_small_width to 155
set target_small_height to 134
set target_large_width to 400
set target_large_height to 400
tell application "Finder"
if not exists volle_foldernaam then
make new folder at pad with properties {name: foldernaam}
end if
duplicate filenaam to volle_foldernaam with replacing
tell application "Image Events"
launch
set this_image to filenaam
copy dimensions of this_image to {W, H}
if target_small_width is greater than target_small_height then
if W is greater than H then
set the scale_length to (W * target_small_height)/H
set the scale_length to round scale_length rounding as taught in school
else
set the scale_length to target_small_height
end if
else if target_small_height is greater than target_small_width then
if H is greater than W then
set the scale_length to (H * target_small_with)/W
set the scale length to round scale_length rounding as taught in school
else
set the scale_length to target_small_width
end if
else
set the scale_length to target_small_height
end if
scale this_image to size scale_length
pad this_image to dimensions {target_small_width, target_small_height}
save this_image as this_name & "__small"
close this_image
end tell
end tell
@ mklement0你改變了什麼?格式仍然是錯誤的,標題中有一個標籤。 – Mark
@Mark:我將「Apple腳本」更改爲「AppleScript」,因爲這是技術和腳本實例的名稱,就像這種情況一樣。 (一般來說:如果標題與標題密切相關,則標題中的標記沒有任何問題)。之前沒有語法突出顯示,所以我添加了<! - language:lang-applescript - >';請注意,雖然AppleScript未得到正式支持,因此突出顯示有時不正確,但仍然最好不要突出顯示。這是你引用的格式錯誤嗎? – mklement0
不,縮進有點小,AFAIK根據指南不應該在標題中加標籤(但這些標籤可能會發生變化,我可能會落後)。 – Mark