50 likes | 148 Views
Example: DisplayTiffInfo. 指導教授 : 黃文楨 學生 :9624707 林宗道. DisplayTiffInfo 程式碼. macro "Display TIFF Info" { if (getVersion>="1.39t") { print("<br>Image description from '"+getTitle+"':"); print(getInfo("image.description")); return; }
E N D
Example: DisplayTiffInfo 指導教授:黃文楨 學生:9624707 林宗道
DisplayTiffInfo 程式碼 macro "Display TIFF Info" { if (getVersion>="1.39t") { print("\nImage description from '"+getTitle+"':"); print(getInfo("image.description")); return; } setBatchMode(true); 背景執行 id = getImageID(); title = getTitle(); if (indexOf(toLowerCase(title), “.tif”)==-1) 沒有找到特定字串 exit("The macro requires a TIFF image"); dir = getDirectory("image"); if (isOpen(“Log”)) { 如果有log時,將關閉”image”且開啟log selectWindow("Log"); run("Close"); }
開啟偵錯控制項(ㄧ) setOption("DebugMode", true); open(dir+title); 開啟新視窗 close(); run("Misc...", "divide=Infinity antialiased"); selectWindow("Log"); info = getInfo(); 把錯誤訊息回傳到getinfo run("Close");
開啟偵錯控制項(二) setOption(“DebugMode”, false); 關閉偵錯控制項 index1 = indexOf(info, "Image Description:"); if (index1==-1) 表示沒有找到特定字串 exit("This TIFF does not appear to have an image description tag"); index1 += 19; index2=indexOf(info, “\n”, index1);找到有”\n”回傳到index1 data = substring(info, index1,index2); (起始索引 ,終止索引) if (lengthOf(data)>200 && indexOf(data, "\n")==-1) exit("The image description is longer than 200 characters."); showMessage ("Image description from "+title, data);
執行結果 • Image description from 'Sunset.jpg':