List of usage examples for com.liferay.portal.kernel.servlet.taglib.ui ImageSelectorProcessor scaleImage
public byte[] scaleImage(int width) throws ImageResolutionException, IOException
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
protected long addSmallImageFileEntry(long userId, long groupId, long entryId, ImageSelector imageSelector) throws PortalException { byte[] imageBytes = imageSelector.getImageBytes(); if (imageBytes == null) { return 0; }/*from www.j a v a2s .c o m*/ try { BlogsGroupServiceSettings blogsGroupServiceSettings = BlogsGroupServiceSettings.getInstance(groupId); ImageSelectorProcessor imageSelectorProcessor = new ImageSelectorProcessor( imageSelector.getImageBytes()); imageBytes = imageSelectorProcessor.scaleImage(blogsGroupServiceSettings.getSmallImageWidth()); if (imageBytes == null) { throw new EntrySmallImageScaleException(); } Folder folder = addSmallImageFolder(userId, groupId); return addProcessedImageFileEntry(userId, groupId, entryId, folder.getFolderId(), imageSelector.getImageTitle(), imageSelector.getImageMimeType(), imageBytes); } catch (IOException ioe) { throw new EntrySmallImageScaleException(); } }