1

I am trying to make something along the lines of this: http://instaprint.me/, however I don't have a dedicated Linux machine, ink-less paper and WiFi. I do, on the other hand, have a desktop connected to the internet and a color photo-printer.

So what I had in mind was this -

  1. Set up an Instagram API App that gets all the information of the most recent photo
  2. A PHP script and a server that can produce a static URL for the most recent photo with a header("Content-Type: image/jpeg"), so that every time I take a new photo, the contents of the image on that static page changes to be the most recent photo.
  3. Other pages, like the one mentioned above, that change to reflect the new location and caption of each photo I take, hosted on a static URL.
  4. Some basic knowledge of Processing.

So here's how for I've got so far - I can download the most recent photo ID, and if it has changed since the last time it checked (15 seconds ago), then it proceeds to download the most recent image, caption and location.

I can then arrange these on the canvas to look like an old-fashioned polaroid. Now the only thing I have to do is print the canvas, at 150dpi, on a piece of 6x4in photo paper.

Anyone got any idea how I could do this?

Alfo
  • 4,801
  • 9
  • 38
  • 51

1 Answers1

1

Focusing on the part about bringing up large images in Processing, I did a Google search and came up with this thread. Quoting their problem and results:

The goal is to print a 180 pdi image with a shape depending on the original canvas. So can be diffrent but it will end up being a 1500x1000mm picture approximately. So a big image. I'm not trying to display it just to dump it into a file.

Then I setup a 64bits JVM. The latest one from Oracle website. Then I created different size of picture and push the memory up to 1024MB. 5000x7500 test OK and 6000x9000 test OK

I tried to setup the memory up to 1500MB, but the JVM was not able to start. So I tried 1200MB 8000x12000 test OK

So it doesn't do the image-printing part but it brings up key information on getting large images in memory via a Java Virtual Machine (JVM).


Lastly, this thread describes a TileSaver class for viewing/printing a large number of pixels using OpenGL. I pasted a large code block below. (This may be unrelated to your question but makes the answer more complete for other uses.)

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;
  }
} 
gary
  • 4,227
  • 3
  • 31
  • 58