[英]Can I use Basil.js to get images from a URL?
我是ExtendScript,Basil.js和Javascript的新手用戶。
看完項目http://basiljs.ch/gallery/ending-the-depression-through-amazon/之后,我想知道是否有可能簡單地獲取Basil.js腳本/ Extendscript / Indesign來從網頁中獲取圖像並插入將其直接轉換為indesign文檔。
我是一個初學者,所以如果有人有一個完整的腳本,可以從目錄,功能...中獲取示例腳本,URL,導入,保存,放置...。
希望我可以簡單地在腳本中添加一個地址,然后將網頁上的所有圖像收集到一個indesign文檔中?
我嘗試了他們的示例http://basiljs.ch/tutorials/getting-images-from-urls/,但是當我復制並在擴展腳本中運行它時,它只是在搜索我的計算機...
更新*
#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basil/basil.js";
function draw() {
var url = "https://raw.github.com/basiljs/basil.js/master/lib/basil.png";
// download the url to a default location, filename according to url:
// -> "the project folder" + data/download/basil.png
//b.download(url);
// download url to a specific location in the project folder:
// -> "the project folder" + data/download_images_files/basil_logo.png
// b.download(url, "download_images_files/basil_logo.png");
// download url to a specific location e.g. to your desktop
// -> ~/Desktop/basil_logo.png
var newFile = new File("~/Desktop/basil_logo.png");
b.download(url, newFile);
}
b.go();
...它在Basil的Core.js @中發現錯誤
var runDrawOnce = function() {
app.doScript(function() {
if (typeof glob.draw === 'function') {
glob.draw();
}
}, ScriptLanguage.javascript, undef, UndoModes.ENTIRE_SCRIPT);
};
控制台說...使用basil.js 1.08 ... sh〜/ Documents / basiljs / bundle / lib / download.sh / Users / jamestk / Desktop(地址,在堆棧溢出時我沒有足夠的聲譽)
Basil.js錯誤-> b.shellExecute():錯誤:sh:/Users/jamestk/Documents/basiljs/bundle/lib/download.sh:沒有此類文件或目錄
最簡單的方法可能是讓我們執行b.shellExecute(cmd)
命令來運行可下載映像的Shell腳本。
您可以使用wget
from shell從URL下載所有圖像,請參見以下問題: 如何使用Wget將所有圖像下載到單個文件夾中
然后,您應確保將圖像保存在文檔數據目錄中。 之后,您可以使用Folder對象的getFiles()
方法獲取所有圖像:
var myImagesArray = Folder('~/path/to/my/folder').getFiles();
最后,您可以循環使用該數組將所有圖像放入文檔中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.