2012-03-13 116 views
1

我正在嘗試做一些事情:http://instaprint.me/,但是我沒有專用的Linux機器,無紙化紙張和WiFi。另一方面,我的桌面連接到互聯網和彩色照片打印機。從處理打印畫布

所以,我腦子裏想的是這樣的 -

  1. 建立一個Instagram的API應用可以得到所有最新的照片
  2. 一個PHP腳本和一個服務器可以產生一個靜態的URL信息對於帶有header("Content-Type: image/jpeg")的最新照片,以便每次拍攝新照片時,該靜態頁面上的圖像內容都會變爲最近的照片。
  3. 其他頁面(如上面提到的那個頁面)會發生變化,以反映我拍攝的每張照片的新位置和標題,並將其置於靜態URL上。
  4. 加工的一些基本知識。

因此,這裏是如何對我這麼遠 - 我可以下載最新的帶照片的身份證,如果它,因爲它檢查(15秒前)最後一次改變的話,就繼續下載最最近的圖像,標題和位置。

然後我可以把它們安排在畫布上看起來像一個老式的寶麗來。現在我唯一要做的就是在150dpi的一張6x4in​​照片紙上打印畫布。

任何人都知道我該如何做到這一點?

回答

1

專注於在Processing中創建大圖像的部分,我做了一個Google搜索,想出了this thread。引用他們的問題和結果:

目標是打印一個180 pdi圖像,其形狀取決於 原始畫布。所以可以是不同的,但它最終會成爲大約1500x1000mm的 圖片。所以一個大的形象。我不想 顯示它只是爲了將其轉儲到一個文件。

然後我設置了一個64位的JVM。最新的一個來自Oracle網站。然後我 創建不同大小的圖片並將內存推到1024MB。 5000x7500測試OK6000x9000測試OK

我試圖安裝的內存高達1500MB,但JVM無法啓動。 所以,我想1200MB 8000x12000測試OK

所以也沒有做圖像印刷的一部分,但它帶來了上通過Java虛擬機(JVM)在內存越來越大圖片關鍵信息。


最後,this thread描述了一種用於觀看/打印大量使用OpenGL像素的TileSaver類。我在下面粘貼了一個大碼塊。 (這可能與您的問題無關,但會讓其他用途的答案更完整。)

import processing.opengl.*; 
import toxi.geom.*; 
Tiler tiler; 

void setup() { 
    size(640,480,OPENGL); 
    tiler=new Tiler((PGraphics3D)g,NUM_TILES); 
} 

void draw() { 
    // see thread 
} 


/** 
* Implements a screen tile exporter with support for FOV, 
* clip planes and flexible file formats. 
* 
* Re-engineered from an older version by Marius Watz: 
* http://workshop.evolutionzone.com/unlekkerlib/ 
* 
* @author toxi <info at postspectacular dot com> 
*/ 
class Tiler { 
    protected PGraphics3D gfx; 
    protected PImage buffer; 
    protected Vec2D[] tileOffsets; 
    protected double top; 
    protected double bottom; 
    protected double left; 
    protected double right; 
    protected Vec2D tileSize; 

    protected int numTiles; 
    protected int tileID; 
    protected float subTileID; 

    protected boolean isTiling; 
    protected String fileName; 
    protected String format; 
    protected double cameraFOV; 
    protected double cameraFar; 
    protected double cameraNear; 

    public Tiler(PGraphics3D g, int n) { 
    gfx = g; 
    numTiles = n; 
    } 

    public void chooseTile(int id) { 
    Vec2D o = tileOffsets[id]; 
    gfx.frustum(o.x, o.x + tileSize.x, o.y, o.y + tileSize.y, 
    (float) cameraNear, (float) cameraFar); 
    } 

    public void initTiles(float fov, float near, float far) { 
    tileOffsets = new Vec2D[numTiles * numTiles]; 
    double aspect = (double) gfx.width/gfx.height; 
    cameraFOV = fov; 
    cameraNear = near; 
    cameraFar = far; 
    top = Math.tan(cameraFOV * 0.5) * cameraNear; 
    bottom = -top; 
    left = aspect * bottom; 
    right = aspect * top; 
    int idx = 0; 
    tileSize = new Vec2D((float) (2 * right/numTiles), (float) (2 * top/numTiles)); 
    double y = top - tileSize.y; 
    while (idx < tileOffsets.length) { 
    double x = left; 
    for (int xi = 0; xi < numTiles; xi++) { 
     tileOffsets[idx++] = new Vec2D((float) x, (float) y); 
     x += tileSize.x; 
    } 
    y -= tileSize.y; 
    } 
    } 

    public void post() { 
    if (isTiling) { 
    subTileID += 0.5; 
    if (subTileID > 1) { 
     int x = tileID % numTiles; 
     int y = tileID/numTiles; 
     gfx.loadPixels(); 
     buffer.set(x * gfx.width, y * gfx.height, gfx); 
     if (tileID == tileOffsets.length - 1) { 
     buffer.save(fileName + "_" + buffer.width + "x" 
     + buffer.height + "." + format); 
     buffer = null; 
     } 
     subTileID = 0; 
     isTiling = (++tileID < tileOffsets.length); 
    } 
    } 
    } 

    public void pre() { 
    if (isTiling) { 
    chooseTile(tileID); 
    } 
    } 

    public void save(String path, String baseName, String format) { 
    (new File(path)).mkdirs(); 
    this.fileName = path + "/" + baseName; 
    this.format = format; 
    buffer = new PImage(gfx.width * numTiles, gfx.height * numTiles); 
    tileID = 0; 
    subTileID = 0; 
    isTiling = true; 
    } 

    public boolean isTiling() { 
    return isTiling; 
    } 
}