List of usage examples for javax.imageio ImageIO scanForPlugins
public static void scanForPlugins()
From source file:com.jaeksoft.searchlib.util.ImageUtils.java
public static void checkPlugins() { ImageIO.scanForPlugins(); if (Logging.isDebug) for (String suffix : ImageIO.getReaderFileSuffixes()) Logging.debug("ImageIO suffix: " + suffix); }
From source file:org.geoserver.GeoserverInitStartupListener.java
public void contextInitialized(ServletContextEvent sce) { // start up tctool - remove it before committing!!!! // new tilecachetool.TCTool().setVisible(true); // make sure we remember if GeoServer controls logging or not String strValue = GeoServerExtensions.getProperty(LoggingUtils.RELINQUISH_LOG4J_CONTROL, sce.getServletContext());/*w ww . j a v a2 s. co m*/ relinquishLoggingControl = Boolean.valueOf(strValue); // if the server admin did not set it up otherwise, force X/Y axis // ordering // This one is a good place because we need to initialize this property // before any other opeation can trigger the initialization of the CRS // subsystem if (System.getProperty("org.geotools.referencing.forceXY") == null) { System.setProperty("org.geotools.referencing.forceXY", "true"); } if (Boolean.TRUE.equals(Hints.getSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER))) { Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "http"); } Hints.putSystemDefault(Hints.LENIENT_DATUM_SHIFT, true); // setup the referencing tolerance to make it more tolerant to tiny differences // between projections (increases the chance of matching a random prj file content // to an actual EPSG code Hints.putSystemDefault(Hints.COMPARISON_TOLERANCE, 1e-9); // don't allow the connection to the EPSG database to time out. This is a server app, // we can afford keeping the EPSG db always on System.setProperty("org.geotools.epsg.factory.timeout", "-1"); // HACK: java.util.prefs are awful. See // http://www.allaboutbalance.com/disableprefs. When the site comes // back up we should implement their better way of fixing the problem. System.setProperty("java.util.prefs.syncInterval", "5000000"); // Fix issue with tomcat and JreMemoryLeakPreventionListener causing issues with // IIORegistry leading to imageio plugins not being properly initialized ImageIO.scanForPlugins(); // HACK: under JDK 1.4.2 the native java image i/o stuff is failing // in all containers besides Tomcat. If running under jdk 1.4.2 we // disable the native codecs, unless the user forced the setting already if (System.getProperty("java.version").startsWith("1.4") && (System.getProperty("com.sun.media.imageio.disableCodecLib") == null)) { LOGGER.warning("Disabling mediaLib acceleration since this is a " + "java 1.4 VM.\n If you want to force its enabling, " // + "set -Dcom.sun.media.imageio.disableCodecLib=true " + "in your virtual machine"); System.setProperty("com.sun.media.imageio.disableCodecLib", "true"); } else { // in any case, the native png reader is worse than the pure java ones, so // let's disable it (the native png writer is on the other side faster)... ImageIOExt.allowNativeCodec("png", ImageReaderSpi.class, false); ImageIOExt.allowNativeCodec("png", ImageWriterSpi.class, true); } // initialize geotools factories so that we don't make a spi lookup every time a factory is needed Hints.putSystemDefault(Hints.FILTER_FACTORY, CommonFactoryFinder.getFilterFactory2(null)); Hints.putSystemDefault(Hints.STYLE_FACTORY, CommonFactoryFinder.getStyleFactory(null)); Hints.putSystemDefault(Hints.FEATURE_FACTORY, CommonFactoryFinder.getFeatureFactory(null)); // initialize the default executor service final ThreadPoolExecutor executor = new ThreadPoolExecutor(CoverageAccessInfoImpl.DEFAULT_CorePoolSize, CoverageAccessInfoImpl.DEFAULT_MaxPoolSize, CoverageAccessInfoImpl.DEFAULT_KeepAliveTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); Hints.putSystemDefault(Hints.EXECUTOR_SERVICE, executor); }
From source file:org.nuxeo.pdf.PDFPageExtractor.java
public BlobList getPagesAsImages(String inFileName) throws NuxeoException { // See https://github.com/levigo/jbig2-imageio#what-if-the-plugin-is-on-classpath-but-not-seen ImageIO.scanForPlugins(); BlobList results = new BlobList(); PDDocument pdfDoc = null;//from w ww . ja va 2 s . c o m String resultFileName = null; // Use file name parameter if passed, otherwise use original file name. if (inFileName == null || inFileName.isEmpty()) { String originalName = pdfBlob.getFilename(); if (originalName == null || originalName.isEmpty()) { originalName = "extracted"; } else { int pos = originalName.toLowerCase().lastIndexOf(".pdf"); if (pos > 0) { originalName = originalName.substring(0, pos); } } inFileName = originalName + ".pdf"; } try { pdfDoc = PDFUtils.load(pdfBlob, password); // Get all PDF pages. @SuppressWarnings("unchecked") List<PDPage> pages = pdfDoc.getDocumentCatalog().getAllPages(); int page = 0; // Convert each page to PNG. for (PDPage pdPage : pages) { ++page; resultFileName = inFileName + "-" + page; BufferedImage bim = pdPage.convertToImage(BufferedImage.TYPE_INT_RGB, 300); File resultFile = Framework.createTempFile(resultFileName, ".png"); FileOutputStream resultFileStream = new FileOutputStream(resultFile); ImageIOUtil.writeImage(bim, "png", resultFileStream, 300); // Convert each PNG to Nuxeo Blob. FileBlob result = new FileBlob(resultFile); result.setFilename(resultFileName + ".png"); result.setMimeType("picture/png"); // Add to BlobList. results.add(result); Framework.trackFile(resultFile, result); } pdfDoc.close(); } catch (IOException e) { throw new NuxeoException("Failed to extract the pages", e); } finally { PDFUtils.closeSilently(pdfDoc); } return results; }