List of usage examples for com.liferay.portal.util PropsValues DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH
int DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH
To view the source code for com.liferay.portal.util PropsValues DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH.
Click Source Link
From source file:com.liferay.portlet.documentlibrary.util.PDFProcessorImpl.java
License:Open Source License
private void _generateImagesIM(FileVersion fileVersion, File file, boolean thumbnail) throws Exception { // Generate images String tempFileId = DLUtil.getTempFileId(fileVersion.getFileEntryId(), fileVersion.getVersion()); IMOperation imOperation = new IMOperation(); imOperation.alpha("off"); imOperation.density(PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_DPI, PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_DPI); if (PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_HEIGHT != 0) { imOperation.adaptiveResize(PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH, PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_HEIGHT); } else {/* ww w.j av a 2s . co m*/ imOperation.adaptiveResize(PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH); } imOperation.depth(PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_DEPTH); if (thumbnail) { imOperation.addImage(file.getPath() + "[0]"); imOperation.addImage(getThumbnailTempFilePath(tempFileId)); } else { imOperation.addImage(file.getPath()); imOperation.addImage(getPreviewTempFilePath(tempFileId, -1)); } if (_log.isInfoEnabled()) { _log.info("Excecuting command 'convert " + imOperation + "'"); } if (PropsValues.DL_FILE_ENTRY_PREVIEW_FORK_PROCESS_ENABLED) { ProcessCallable<String> processCallable = new ImageMagickProcessCallable(_globalSearchPath, imOperation.getCmdArgs()); ProcessExecutor.execute(processCallable, ClassPathUtil.getPortalClassPath()); } else { _convertCmd.run(imOperation); } // Store images if (thumbnail) { File thumbnailTempFile = getThumbnailTempFile(tempFileId); try { storeThumbnailImages(fileVersion, thumbnailTempFile); } finally { FileUtil.delete(thumbnailTempFile); } } else { // ImageMagick converts single page PDFs without appending an // index. Rename file for consistency. File singlePagePreviewFile = getPreviewTempFile(tempFileId, -1); if (singlePagePreviewFile.exists()) { singlePagePreviewFile.renameTo(getPreviewTempFile(tempFileId, 1)); } int total = getPreviewTempFileCount(fileVersion); for (int i = 0; i < total; i++) { File previewTempFile = getPreviewTempFile(tempFileId, i + 1); try { addFileToStore(fileVersion.getCompanyId(), PREVIEW_PATH, getPreviewFilePath(fileVersion, i + 1), previewTempFile); } finally { FileUtil.delete(previewTempFile); } } } }
From source file:com.liferay.portlet.documentlibrary.util.PDFProcessorImpl.java
License:Open Source License
private void _generateImagesPB(FileVersion fileVersion, PDPage pdPage, int index) throws Exception { // Generate images RenderedImage renderedImage = pdPage.convertToImage(BufferedImage.TYPE_INT_RGB, PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_DPI); if (PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_HEIGHT != 0) { renderedImage = ImageToolUtil.scale(renderedImage, PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH, PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_HEIGHT); } else {/*from ww w . j a va 2 s . c o m*/ renderedImage = ImageToolUtil.scale(renderedImage, PropsValues.DL_FILE_ENTRY_PREVIEW_DOCUMENT_MAX_WIDTH); } // Store images if (index == 0) { storeThumbnailImages(fileVersion, renderedImage); } else { File tempFile = null; try { String tempFileId = DLUtil.getTempFileId(fileVersion.getFileEntryId(), fileVersion.getVersion()); tempFile = getPreviewTempFile(tempFileId, index); tempFile.createNewFile(); ImageIO.write(renderedImage, PREVIEW_TYPE, new FileOutputStream(tempFile)); addFileToStore(fileVersion.getCompanyId(), PREVIEW_PATH, getPreviewFilePath(fileVersion, index), tempFile); } finally { FileUtil.delete(tempFile); } } }