示例#1
0
  @Test
  public void testTilingSpead() throws Exception {
    PictureTilingService pts = Framework.getLocalService(PictureTilingService.class);
    assertNotNull(pts);

    File file = FileUtils.getResourceFileFromContext("test.jpg");
    Blob image = Blobs.createBlob(file);

    GimpExecutor.setUseQuickExec(false);
    image.setFilename("slow.jpg");
    PictureTiles tiles = pts.getTilesFromBlob(image, 255, 255, 20, 0, 0, false);
    assertNotNull(tiles);
    assertFalse(tiles.getZoomfactor() == 0);
    // System.out.println("ExecTime="
    // + tiles.getInfo().get("JavaProcessExecTime"));

    GimpExecutor.setUseQuickExec(true);
    image.setFilename("quick.jpg");
    PictureTiles tiles2 = pts.getTilesFromBlob(image, 255, 255, 20, 0, 0, false);
    assertNotNull(tiles2);
    assertFalse(tiles2.getZoomfactor() == 0);
    // System.out.println("ExecTime="
    // + tiles2.getInfo().get("JavaProcessExecTime"));

    GimpExecutor.setUseQuickExec(false);
  }
示例#2
0
  @Test
  public void testBorderTiles() throws Exception {
    PictureTilingService pts = Framework.getLocalService(PictureTilingService.class);
    assertNotNull(pts);
    PictureTilingComponent.setDefaultTiler(new MagickTiler());
    File file = FileUtils.getResourceFileFromContext("chutes.jpg");
    Blob image = Blobs.createBlob(file);
    PictureTiles tiles = pts.getTilesFromBlob(image, 64, 64, 3);
    assertNotNull(tiles);

    tiles.getTile(2, 1);
    String tilePath = ((PictureTilesImpl) tiles).getTileFilePath(2, 1);
    ImageInfo info = ImageIdentifier.getInfo(tilePath);
    int width = info.getWidth();
    int height = info.getHeight();
    if (width == 63) {
      width = 64; // tolerance for rounding
    }
    assertEquals(64, width);
    assertEquals(64, height);

    tiles.getTile(2, 2);
    tilePath = ((PictureTilesImpl) tiles).getTileFilePath(2, 2);
    info = ImageIdentifier.getInfo(tilePath);
    width = info.getWidth();
    height = info.getHeight();
    if (width == 63) {
      width = 64; // tolerance for rounding
    }
    if (height == 15) {
      height = 16; // tolerance for rounding
    }
    assertEquals(64, width);
    assertEquals(16, height);
  }
示例#3
0
  @Test
  @Ignore
  public void testBig() throws Exception {
    PictureTilingService pts = Framework.getLocalService(PictureTilingService.class);
    assertNotNull(pts);
    PictureTilingComponent.setDefaultTiler(new MagickTiler());
    File file = new File("/home/tiry/photos/orion.jpg");
    Blob image = Blobs.createBlob(file);

    long t0 = System.currentTimeMillis();
    PictureTiles tiles = pts.getTilesFromBlob(image, 100, 100, 180);
    assertNotNull(tiles);
    long t1 = System.currentTimeMillis();

    System.out.println(
        "Big picture "
            + tiles.getOriginalImageInfo().getWidth()
            + "x"
            + tiles.getOriginalImageInfo().getHeight()
            + " at zoom "
            + tiles.getZoomfactor()
            + " generated in "
            + (t1 - t0)
            + "ms");
  }
示例#4
0
  @Test
  public void testLazy() throws Exception {
    PictureTilingService pts = Framework.getLocalService(PictureTilingService.class);
    assertNotNull(pts);

    String wdirPath = System.getProperty("java.io.tmpdir") + "/testMe";
    new File(wdirPath).mkdir();
    pts.setWorkingDirPath(wdirPath);

    File file = FileUtils.getResourceFileFromContext("test.jpg");
    Blob image = Blobs.createBlob(file);

    image.setFilename("test.jpg");
    PictureTiles tiles = pts.getTilesFromBlob(image, 255, 255, 20, 0, 0, false);

    assertNotNull(tiles);

    Blob tile00 = tiles.getTile(0, 0);
    assertNotNull(tile00);

    Blob tile01 = tiles.getTile(0, 1);
    assertNotNull(tile01);

    Blob tile02 = tiles.getTile(0, 2);
    assertNotNull(tile02);
  }
示例#5
0
  @Test
  public void testMagick2() throws Exception {
    PictureTilingService pts = Framework.getLocalService(PictureTilingService.class);
    assertNotNull(pts);
    PictureTilingComponent.setDefaultTiler(new MagickTiler());
    File file = FileUtils.getResourceFileFromContext("test.jpg");
    Blob image = Blobs.createBlob(file);
    PictureTiles tiles = pts.getTilesFromBlob(image, 200, 160, 2);
    assertNotNull(tiles);

    tiles.getTile(0, 1);
  }
示例#6
0
  @Test
  public void testTilingSimple() throws Exception {
    PictureTilingService pts = Framework.getLocalService(PictureTilingService.class);
    assertNotNull(pts);

    File file = FileUtils.getResourceFileFromContext("test.jpg");
    Blob image = Blobs.createBlob(file);

    PictureTiles tiles = pts.getTilesFromBlob(image, 255, 255, 20);

    assertNotNull(tiles);
    assertFalse(tiles.getZoomfactor() == 0);
  }
示例#7
0
  protected void benchTiler(PictureTilingService pts, PictureTiler tiler) throws Exception {

    PictureTilingComponent.setDefaultTiler(tiler);
    File file = FileUtils.getResourceFileFromContext("test.jpg");
    Blob image = Blobs.createBlob(file);
    long t0 = System.currentTimeMillis();
    int nb = 0;

    for (int maxTiles = 2; maxTiles < 5; maxTiles = maxTiles + 2) {

      long tt0 = System.currentTimeMillis();

      PictureTiles tiles = pts.getTilesFromBlob(image, 200, 200, maxTiles);
      assertNotNull(tiles);

      int nxt = tiles.getXTiles();
      int nyt = tiles.getYTiles();
      int nbt = 0;
      for (int i = 0; i < nxt; i++) {
        for (int j = 0; j < nyt; j++) {
          nbt++;
          long t1 = System.currentTimeMillis();
          Blob tile = tiles.getTile(i, j);
          long t2 = System.currentTimeMillis();

          // System.out.println("maxTile=" + maxTiles + " " + i + "-"
          // + j + " :" + (t2 - t1));
        }
      }
      nb = nb + nbt;
      long tt1 = System.currentTimeMillis();
      // System.out.println("maxTile=" + maxTiles
      // + " total generation time :" + (tt1 - tt0));
      // System.out.println("speed " + (nbt + 0.0) / ((tt1 - tt0) / 1000));
    }

    long t3 = System.currentTimeMillis();

    // System.out.println("complete run for tiler : " + tiler.getName() +
    // " :" + (t3 - t0));
    // System.out.println("speed " + (nb + 0.0) / ((t3 - t0) / 1000));
  }