@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); }
@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"); }
@Before public void setUp() throws Exception { super.setUp(); deployContrib("org.nuxeo.ecm.platform.pictures.tiles", "OSGI-INF/pictures-tiles-framework.xml"); deployBundle("org.nuxeo.ecm.platform.commandline.executor"); deployContrib( "org.nuxeo.ecm.platform.picture.core", "OSGI-INF/commandline-imagemagick-contrib.xml"); PictureTilingComponent.getCache().clear(); PictureTilingComponent.setDefaultTiler(new MagickTiler()); PictureTilingComponent.endGC(); }
@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); }
@Test public void testTilingSimpleMagick() 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, 255, 255, 5); assertNotNull(tiles); assertFalse(tiles.getZoomfactor() == 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)); }