Removed the watermarker jar and the code that was dependent on it because Watermarker is a dead project and the jar is no more publicly available, so we will not be able to run it in releases.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1751819 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -119,7 +119,6 @@ framework/webapp/lib/serializer-2.7.0.jar
|
||||
framework/webapp/lib/xalan-2.7.1.jar
|
||||
applications/content/lib/poi-3.13-20150929.jar
|
||||
applications/product/lib/dozer-4.2.1.jar
|
||||
applications/product/lib/watermarker-0.0.4.jar
|
||||
tools/security/notsoserial/notsoserial-1.0-SNAPSHOT.jar
|
||||
specialpurpose/passport/lib/commons-httpclient-3.1.jar
|
||||
|
||||
|
||||
@@ -8624,15 +8624,6 @@
|
||||
<value xml:lang="zh">图片上传列表</value>
|
||||
<value xml:lang="zh-TW">圖片上傳清單</value>
|
||||
</property>
|
||||
<property key="ImageManagementImageWatermarking">
|
||||
<value xml:lang="de">Bild Wasserzeichen</value>
|
||||
<value xml:lang="en">Image Watermarking</value>
|
||||
<value xml:lang="ja">画像透かし</value>
|
||||
<value xml:lang="th">ลายน้ำรูปภาพ</value>
|
||||
<value xml:lang="vi">Lọc mờ ảnh</value>
|
||||
<value xml:lang="zh">图片水印</value>
|
||||
<value xml:lang="zh-TW">圖片浮水印</value>
|
||||
</property>
|
||||
<property key="ImageManagementImageWidth">
|
||||
<value xml:lang="de">Bildbreite</value>
|
||||
<value xml:lang="en">Image Width</value>
|
||||
@@ -8801,24 +8792,6 @@
|
||||
<value xml:lang="zh">上传新的框</value>
|
||||
<value xml:lang="zh-TW">上傳新的框</value>
|
||||
</property>
|
||||
<property key="ImageManagementWatermark">
|
||||
<value xml:lang="de">Wasserzeichen</value>
|
||||
<value xml:lang="en">Watermark</value>
|
||||
<value xml:lang="ja">透かし</value>
|
||||
<value xml:lang="th">ลายน้ำ</value>
|
||||
<value xml:lang="vi">Làm mờ</value>
|
||||
<value xml:lang="zh">水印</value>
|
||||
<value xml:lang="zh-TW">浮水印</value>
|
||||
</property>
|
||||
<property key="ImageManagementWatermarkingLocation">
|
||||
<value xml:lang="de">Direkt auf das Bild klicken um die Position des Wasserzeichens anzupassen</value>
|
||||
<value xml:lang="en">Click directly on the image to adjust the location of the watermark</value>
|
||||
<value xml:lang="fr">Cliquer directement sur l'image pour positionner le filigrane</value>
|
||||
<value xml:lang="ja">透かしの位置を調整するには画像を直接クリックしてください</value>
|
||||
<value xml:lang="vi">Bấm trực tiếp lên ảnh để điều chỉnh vị trí làm mờ</value>
|
||||
<value xml:lang="zh">直接点击在图片上来调整水印位置</value>
|
||||
<value xml:lang="zh-TW">直接點擊在圖片上來調整浮水印位置</value>
|
||||
</property>
|
||||
<property key="ImageManagementWelcomeMessage">
|
||||
<value xml:lang="de">Willkommen in der Bildbearbeitung</value>
|
||||
<value xml:lang="en">Welcome to the Image Management</value>
|
||||
|
||||
@@ -123,11 +123,11 @@
|
||||
<section>
|
||||
<title>Manage</title>
|
||||
<section>
|
||||
<para>You can edit image such as add frame, embedded watermark, crop image etc. You can also add caption, sort order, enable image and choose thumbnail in this function.</para>
|
||||
<para>You can edit image such as add frame, crop image etc. You can also add caption, sort order, enable image and choose thumbnail in this function.</para>
|
||||
<para>Note: You must have Image Management Admin permission for access this function.</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Click 'Manage' Button, then you can choose action including 'Frame', 'Watermark', 'Crop' and 'Rotate' (see below for more details).</para>
|
||||
<para>Click 'Manage' Button, then you can choose action including 'Frame', 'Crop' and 'Rotate' (see below for more details).</para>
|
||||
<para>Enter your image caption.</para>
|
||||
<para>Sort order of image by enter order number.</para>
|
||||
<para>Enable image by tick enable checkbox.</para>
|
||||
@@ -152,20 +152,6 @@
|
||||
</orderedlist>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>- Watermark</title>
|
||||
<section>
|
||||
<para>In Watermark function, you can draw some text on your image.</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Choose 'Watermark' then choose image you want.</para>
|
||||
<para>Enter any text, Choose text color, text size and text position.</para>
|
||||
<para>Optional, you can preview image by click 'Preview' button.</para>
|
||||
<para>Click 'Watermark' button.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>- Crop</title>
|
||||
<section>
|
||||
|
||||
Binary file not shown.
@@ -1,422 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*******************************************************************************/
|
||||
package org.ofbiz.product.imagemanagement;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilDateTime;
|
||||
import org.ofbiz.base.util.UtilGenerics;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
import org.ofbiz.base.util.string.FlexibleStringExpander;
|
||||
import org.ofbiz.entity.Delegator;
|
||||
import org.ofbiz.entity.GenericEntityException;
|
||||
import org.ofbiz.entity.GenericValue;
|
||||
import org.ofbiz.entity.util.EntityQuery;
|
||||
import org.ofbiz.entity.util.EntityUtilProperties;
|
||||
import org.ofbiz.service.GenericServiceException;
|
||||
import org.ofbiz.service.LocalDispatcher;
|
||||
import org.ofbiz.service.ServiceUtil;
|
||||
|
||||
import watermarker.exception.WatermarkerException;
|
||||
import watermarker.impl.DefaultWatermarker;
|
||||
import watermarker.model.WatermarkSettings;
|
||||
import watermarker.model.WatermarkerSettings;
|
||||
|
||||
public class WatermarkImage{
|
||||
|
||||
public static final String module = WatermarkImage.class.getName();
|
||||
public static final String resource = "ProductErrorUiLabels";
|
||||
|
||||
public static String createWatermarkImage(HttpServletRequest request, HttpServletResponse response) throws WatermarkerException, IOException {
|
||||
Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.path", delegator), context);
|
||||
String imageServerUrl = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.url", delegator), context);
|
||||
String nameOfThumb = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.nameofthumbnail", delegator), context);
|
||||
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
|
||||
GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
|
||||
String watermarkText = null;
|
||||
URL imageUrl = null;
|
||||
String productId = request.getParameter("productId");
|
||||
String imageName = request.getParameter("imageName");
|
||||
String text = request.getParameter("textWatermark");
|
||||
String opacity = request.getParameter("opacity");
|
||||
String x = request.getParameter("pointX");
|
||||
String y = request.getParameter("pointY");
|
||||
String width = request.getParameter("width");
|
||||
String count = request.getParameter("count");
|
||||
String fontColor = request.getParameter("colorWatermark");
|
||||
String fontSize = request.getParameter("sizeWatermark");
|
||||
|
||||
File file = new File(imageServerPath + "/preview/" + "/previewImage" + count + ".jpg");
|
||||
file.delete();
|
||||
try {
|
||||
if (UtilValidate.isNotEmpty(imageName)) {
|
||||
imageUrl = new URL("file:" + imageServerPath + "/" + productId + "/" + imageName);
|
||||
} else {
|
||||
String errMsg = "Please select Image.";
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
if (UtilValidate.isNotEmpty(text)) {
|
||||
watermarkText = text;
|
||||
} else {
|
||||
String errMsg = "Please enter Text.";
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
WatermarkerSettings watermarkerSettings = WatermarkerSettings.DEFAULT;
|
||||
|
||||
if (UtilValidate.isNotEmpty(fontColor)) {
|
||||
Color graphicsColor = setFontColor(fontColor);
|
||||
watermarkerSettings.setGraphicsColor(graphicsColor);
|
||||
} else {
|
||||
String errMsg = "Please select Text Color.";
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
DecimalFormat decimalFormat = new DecimalFormat();
|
||||
decimalFormat.applyPattern("0.00");
|
||||
if (UtilValidate.isNotEmpty(fontSize)) {
|
||||
BigDecimal widthBase = new BigDecimal(600.00);
|
||||
BigDecimal picWidth = new BigDecimal(decimalFormat.format(Float.parseFloat(width)));
|
||||
Font graphicsFont = setFontSize(fontSize, picWidth.divide(widthBase, 2));
|
||||
watermarkerSettings.setGraphicsFont(graphicsFont);
|
||||
} else {
|
||||
String errMsg = "Please select Text Size.";
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
WatermarkSettings position = new WatermarkSettings();
|
||||
if (UtilValidate.isNotEmpty(x) && UtilValidate.isNotEmpty(y)) {
|
||||
BigDecimal positionX = new BigDecimal(decimalFormat.format(Float.parseFloat(x)));
|
||||
BigDecimal positionY = new BigDecimal(decimalFormat.format(Float.parseFloat(y)));
|
||||
position.setX(positionX.floatValue());
|
||||
position.setY(positionY.floatValue());
|
||||
watermarkerSettings.setWatermarkSettings(position);
|
||||
} else {
|
||||
String errMsg = "Please select Text Position.";
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
AlphaComposite alphaComposite = null;
|
||||
if (UtilValidate.isNotEmpty(opacity)) {
|
||||
BigDecimal opa = new BigDecimal(opacity);
|
||||
alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opa.floatValue());
|
||||
watermarkerSettings.setAlphaComposite(alphaComposite);
|
||||
}
|
||||
|
||||
if (UtilValidate.isNotEmpty(imageUrl)) {
|
||||
|
||||
Map<String, Object> contentCtx = new HashMap<String, Object>();
|
||||
contentCtx.put("contentTypeId", "DOCUMENT");
|
||||
contentCtx.put("userLogin", userLogin);
|
||||
Map<String, Object> contentResult = new HashMap<String, Object>();
|
||||
try {
|
||||
contentResult = dispatcher.runSync("createContent", contentCtx);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, module);
|
||||
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
|
||||
return "error";
|
||||
}
|
||||
|
||||
Map<String, Object> contentThumb = new HashMap<String, Object>();
|
||||
contentThumb.put("contentTypeId", "DOCUMENT");
|
||||
contentThumb.put("userLogin", userLogin);
|
||||
Map<String, Object> contentThumbResult = new HashMap<String, Object>();
|
||||
try {
|
||||
contentThumbResult = dispatcher.runSync("createContent", contentThumb);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, module);
|
||||
return e.getMessage();
|
||||
}
|
||||
|
||||
String contentIdThumb = (String) contentThumbResult.get("contentId");
|
||||
String contentId = (String) contentResult.get("contentId");
|
||||
String filenameToUse = (String) contentResult.get("contentId") + ".jpg";
|
||||
String filenameTouseThumb = (String) contentResult.get("contentId") + nameOfThumb + ".jpg";
|
||||
File outputImageFile = new File(imageServerPath + "/" + productId + "/" + filenameToUse);
|
||||
OutputStream outputStream = new FileOutputStream(outputImageFile);
|
||||
|
||||
// *** Actual call to Watermarker#watermark(...) ***
|
||||
new DefaultWatermarker().watermark(imageUrl, watermarkText, outputStream, watermarkerSettings);
|
||||
|
||||
String imageUrlResource = imageServerUrl + "/" + productId + "/" + filenameToUse;
|
||||
|
||||
BufferedImage bufNewImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + filenameToUse));
|
||||
|
||||
double imgHeight = bufNewImg.getHeight();
|
||||
double imgWidth = bufNewImg.getWidth();
|
||||
String mimeType = imageName.substring(imageName.lastIndexOf(".") + 1);
|
||||
|
||||
Map<String, Object> resultResize = ImageManagementServices.resizeImageThumbnail(bufNewImg, imgHeight, imgWidth);
|
||||
ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + "/" + productId + "/" + filenameTouseThumb));
|
||||
|
||||
String imageUrlThumb = imageServerUrl + "/" + productId + "/" + filenameTouseThumb;
|
||||
|
||||
createContentAndDataResourceWaterMark(request, userLogin, filenameToUse, imageUrlResource, contentId, "image/jpeg");
|
||||
createContentAndDataResourceWaterMark(request, userLogin, filenameTouseThumb, imageUrlThumb, contentIdThumb, "image/jpeg");
|
||||
|
||||
Map<String, Object> createContentAssocMap = new HashMap<String, Object>();
|
||||
createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL");
|
||||
createContentAssocMap.put("contentId", contentId);
|
||||
createContentAssocMap.put("contentIdTo", contentIdThumb);
|
||||
createContentAssocMap.put("userLogin", userLogin);
|
||||
createContentAssocMap.put("mapKey", "100");
|
||||
try {
|
||||
dispatcher.runSync("createContentAssoc", createContentAssocMap);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, module);
|
||||
return e.getMessage();
|
||||
}
|
||||
|
||||
Map<String, Object> productContentCtx = new HashMap<String, Object>();
|
||||
productContentCtx.put("productId", productId);
|
||||
productContentCtx.put("productContentTypeId", "IMAGE");
|
||||
productContentCtx.put("fromDate", UtilDateTime.nowTimestamp());
|
||||
productContentCtx.put("userLogin", userLogin);
|
||||
productContentCtx.put("contentId", contentId);
|
||||
productContentCtx.put("statusId", "IM_PENDING");
|
||||
try {
|
||||
dispatcher.runSync("createProductContent", productContentCtx);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, module);
|
||||
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());return "error";
|
||||
}
|
||||
|
||||
Map<String, Object> contentApprovalCtx = new HashMap<String, Object>();
|
||||
contentApprovalCtx.put("contentId", contentId);
|
||||
contentApprovalCtx.put("userLogin", userLogin);
|
||||
try {
|
||||
dispatcher.runSync("createImageContentApproval", contentApprovalCtx);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, module);
|
||||
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());return "error";
|
||||
}
|
||||
}
|
||||
} catch (WatermarkerException e) {
|
||||
String errMsg = "Cannot create watermark.";
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
Debug.logError(e, errMsg, module);
|
||||
return "error";
|
||||
}
|
||||
String eventMsg = "Watermark image successfully.";
|
||||
request.setAttribute("_EVENT_MESSAGE_", eventMsg);
|
||||
return "success";
|
||||
}
|
||||
|
||||
public static Map<String, Object> createContentAndDataResourceWaterMark(HttpServletRequest request, GenericValue userLogin, String filenameToUse, String imageUrl, String contentId, String mimeTypeId){
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
|
||||
Map<String, Object> dataResourceCtx = new HashMap<String, Object>();
|
||||
|
||||
dataResourceCtx.put("objectInfo", imageUrl);
|
||||
dataResourceCtx.put("dataResourceName", filenameToUse);
|
||||
dataResourceCtx.put("userLogin", userLogin);
|
||||
dataResourceCtx.put("dataResourceTypeId", "IMAGE_OBJECT");
|
||||
dataResourceCtx.put("mimeTypeId", mimeTypeId);
|
||||
dataResourceCtx.put("isPublic", "Y");
|
||||
|
||||
Map<String, Object> dataResourceResult = new HashMap<String, Object>();
|
||||
try {
|
||||
dataResourceResult = dispatcher.runSync("createDataResource", dataResourceCtx);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, module);
|
||||
return ServiceUtil.returnError(e.getMessage());
|
||||
}
|
||||
|
||||
Map<String, Object> contentUp = new HashMap<String, Object>();
|
||||
contentUp.put("contentId", contentId);
|
||||
contentUp.put("dataResourceId", dataResourceResult.get("dataResourceId"));
|
||||
contentUp.put("contentName", filenameToUse);
|
||||
contentUp.put("userLogin", userLogin);
|
||||
try {
|
||||
dispatcher.runSync("updateContent", contentUp);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, module);
|
||||
return ServiceUtil.returnError(e.getMessage());
|
||||
}
|
||||
|
||||
GenericValue content = null;
|
||||
try {
|
||||
content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, module);
|
||||
return ServiceUtil.returnError(e.getMessage());
|
||||
}
|
||||
|
||||
if (content != null) {
|
||||
GenericValue dataResource = null;
|
||||
try {
|
||||
dataResource = content.getRelatedOne("DataResource", false);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, module);
|
||||
return ServiceUtil.returnError(e.getMessage());
|
||||
}
|
||||
|
||||
if (dataResource != null) {
|
||||
dataResourceCtx.put("dataResourceId", dataResource.getString("dataResourceId"));
|
||||
try {
|
||||
dispatcher.runSync("updateDataResource", dataResourceCtx);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, module);
|
||||
return ServiceUtil.returnError(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String setPreviewWaterMark(HttpServletRequest request, HttpServletResponse response) {
|
||||
Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.path", delegator), context);
|
||||
String productId = request.getParameter("productId");
|
||||
String imageName = request.getParameter("imageName");
|
||||
String text = request.getParameter("text");
|
||||
String opacity = request.getParameter("opacity");
|
||||
String x = request.getParameter("x");
|
||||
String y = request.getParameter("y");
|
||||
String width = request.getParameter("width");
|
||||
String count = request.getParameter("count");
|
||||
String fontColor = request.getParameter("fontColor");
|
||||
String fontSize = request.getParameter("fontSize");
|
||||
|
||||
String dirPath = "/preview/";
|
||||
File dir = new File(imageServerPath + dirPath);
|
||||
if (!dir.exists()) {
|
||||
boolean createDir = dir.mkdir();
|
||||
if (!createDir) {
|
||||
request.setAttribute("_ERROR_MESSAGE_", "Cannot create directory.");
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
BigDecimal opa = new BigDecimal(opacity);
|
||||
DecimalFormat decimalFormat = new DecimalFormat();
|
||||
decimalFormat.applyPattern("0.00");
|
||||
BigDecimal positionX = new BigDecimal(decimalFormat.format(Float.parseFloat(x)));
|
||||
BigDecimal positionY = new BigDecimal(decimalFormat.format(Float.parseFloat(y)));
|
||||
BigDecimal picWidth = new BigDecimal(decimalFormat.format(Float.parseFloat(width)));
|
||||
File file = new File(imageServerPath + "/preview/" + "/previewImage" + count + ".jpg");
|
||||
file.delete();
|
||||
BigDecimal widthBase = new BigDecimal(600.00);
|
||||
Integer currentPic = Integer.parseInt(count);
|
||||
int nextPic = currentPic.intValue() + 1;
|
||||
AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opa.floatValue());
|
||||
WatermarkSettings position = new WatermarkSettings();
|
||||
position.setX(positionX.floatValue());
|
||||
position.setY(positionY.floatValue());
|
||||
Color graphicsColor = setFontColor(fontColor);
|
||||
Font graphicsFont = setFontSize(fontSize, picWidth.divide(widthBase, 2));
|
||||
WatermarkerSettings watermarkerSettings = WatermarkerSettings.DEFAULT;
|
||||
watermarkerSettings.setGraphicsColor(graphicsColor);
|
||||
watermarkerSettings.setGraphicsFont(graphicsFont);
|
||||
watermarkerSettings.setWatermarkSettings(position);
|
||||
watermarkerSettings.setAlphaComposite(alphaComposite);
|
||||
try {
|
||||
URL imageUrl = new URL("file:" + imageServerPath + "/" + productId + "/" + imageName);
|
||||
File outputImageFile = new File(imageServerPath + "/preview/" + "/previewImage" + nextPic + ".jpg");
|
||||
OutputStream outputStream = new FileOutputStream(outputImageFile);
|
||||
|
||||
new DefaultWatermarker().watermark(imageUrl, text, outputStream, watermarkerSettings);
|
||||
|
||||
} catch (Exception e) {
|
||||
String errMsg = "Error from setPreviewWaterMark";
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
return "success";
|
||||
}
|
||||
|
||||
public static String deletePreviewWatermarkImage(HttpServletRequest request, HttpServletResponse response) {
|
||||
Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.path", delegator), context);
|
||||
String count = request.getParameter("count");
|
||||
File file = new File(imageServerPath + "/preview/" + "/previewImage" + count + ".jpg");
|
||||
file.delete();
|
||||
|
||||
return "success";
|
||||
}
|
||||
|
||||
private static Color setFontColor(String color) {
|
||||
Color graphicsColor = null;
|
||||
if (color.equals("TEXT_BLACK")) {
|
||||
graphicsColor = Color.BLACK;
|
||||
} else if (color.equals("TEXT_WHITE")) {
|
||||
graphicsColor = Color.WHITE;
|
||||
} else if (color.equals("TEXT_GRAY")) {
|
||||
graphicsColor = Color.GRAY;
|
||||
} else if(color.equals("TEXT_RED")) {
|
||||
graphicsColor = Color.RED;
|
||||
} else if(color.equals("TEXT_GREEN")) {
|
||||
graphicsColor = Color.GREEN;
|
||||
} else if(color.equals("TEXT_BLUE")) {
|
||||
graphicsColor = Color.BLUE;
|
||||
} else if(color.equals("TEXT_YELLOW")) {
|
||||
graphicsColor = Color.YELLOW;
|
||||
}
|
||||
return graphicsColor;
|
||||
}
|
||||
|
||||
private static Font setFontSize(String fontSize, BigDecimal multiply) {
|
||||
Font graphicsFont = null;
|
||||
BigDecimal baseSize = null;
|
||||
if (fontSize.equals("TEXT_SMALL")) {
|
||||
baseSize = new BigDecimal(24.00);
|
||||
graphicsFont = new Font( "Arial", Font.BOLD, baseSize.multiply(multiply).intValue());
|
||||
} else if (fontSize.equals("TEXT_MIDDLE")) {
|
||||
baseSize = new BigDecimal(36.00);
|
||||
graphicsFont = new Font( "Arial", Font.BOLD, baseSize.multiply(multiply).intValue());
|
||||
} else if (fontSize.equals("TEXT_LARGE")) {
|
||||
baseSize = new BigDecimal(48.00);
|
||||
graphicsFont = new Font( "Arial", Font.BOLD, baseSize.multiply(multiply).intValue());
|
||||
} else if (fontSize.equals("TEXT_VERYLARGE")) {
|
||||
baseSize = new BigDecimal(60.00);
|
||||
graphicsFont = new Font( "Arial", Font.BOLD, baseSize.multiply(multiply).intValue());
|
||||
}
|
||||
return graphicsFont;
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
<#--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<script language="javascript" type="text/javascript" src="<@ofbizContentUrl>/images/imagemanagement/sizzle.min.js</@ofbizContentUrl>"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery.noConflict();
|
||||
var host = document.location.host;
|
||||
jQuery(document).ready(function() {
|
||||
var productId = jQuery('#ImageWatermarking_productId').val();
|
||||
var imageName = jQuery('#ImageWatermarking_imageName').val();
|
||||
|
||||
jQuery('td.img-src img').click(function(e) {
|
||||
var previewCount = jQuery('#ImageWatermarking_previewCount').val();
|
||||
var next = parseInt(previewCount) + 1;
|
||||
imgOffset = jQuery('td.img-src img').offset();
|
||||
var pointX = parseInt(e.pageX - imgOffset.left);
|
||||
var pointY = parseInt(e.pageY - imgOffset.top);
|
||||
jQuery('#ImageWatermarking_positionX').attr('value', pointX);
|
||||
jQuery('#ImageWatermarking_positionY').attr('value', pointY);
|
||||
getPreviewImage(next);
|
||||
});
|
||||
jQuery('td.preview a').click(function() {
|
||||
var previewCount = jQuery('#ImageWatermarking_previewCount').val();
|
||||
var next = parseInt(previewCount) + 1;
|
||||
getPreviewImage(next);
|
||||
});
|
||||
jQuery('td.txt_color select').change(function() {
|
||||
var previewCount = jQuery('#ImageWatermarking_previewCount').val();
|
||||
var next = parseInt(previewCount) + 1;
|
||||
getPreviewImage(next);
|
||||
});
|
||||
jQuery('td.txt_size select').change(function() {
|
||||
var previewCount = jQuery('#ImageWatermarking_previewCount').val();
|
||||
var next = parseInt(previewCount) + 1;
|
||||
getPreviewImage(next);
|
||||
});
|
||||
jQuery('td.opacity select').change(function() {
|
||||
var previewCount = jQuery('#ImageWatermarking_previewCount').val();
|
||||
var next = parseInt(previewCount) + 1;
|
||||
getPreviewImage(next);
|
||||
});
|
||||
jQuery('td.img-src img').ajaxStart(function() {
|
||||
jQuery(this).attr('style', 'opacity:0.6;filter:alpha(opacity=40)');
|
||||
});
|
||||
jQuery('td.img-src img').load(function() {
|
||||
jQuery(this).attr('style', 'opacity:1.0;filter:alpha(opacity=100)');
|
||||
});
|
||||
});
|
||||
jQuery(window).load(function() {
|
||||
var width = jQuery('td.img-src img').width();
|
||||
var height = jQuery('td.img-src img').height();
|
||||
jQuery('#ImageWatermarking_width').attr('value', width);
|
||||
jQuery('#ImageWatermarking_height').attr('value', height);
|
||||
});
|
||||
function getPreviewImage(next) {
|
||||
var imageServerUrl = jQuery('#ImageWatermarking_imageServerUrl').val();
|
||||
var productId = jQuery('#ImageWatermarking_productId').val();
|
||||
var imageName = jQuery('#ImageWatermarking_imageName').val();
|
||||
var width = jQuery('#ImageWatermarking_width').val();
|
||||
var height = jQuery('#ImageWatermarking_height').val();
|
||||
var positionX = jQuery('#ImageWatermarking_positionX').val();
|
||||
var positionY = jQuery('#ImageWatermarking_positionY').val();
|
||||
var pointX = parseFloat(positionX / width);
|
||||
var pointY = parseFloat(positionY / height);
|
||||
var text = jQuery('td.watermark_txt input').val();
|
||||
var opacity = jQuery('td.opacity select').val();
|
||||
var fontColor = jQuery('td.txt_color select').val();
|
||||
var fontSize = jQuery('td.txt_size select').val();
|
||||
var previewCount = jQuery('#ImageWatermarking_previewCount').val();
|
||||
var imageData = {productId : productId, imageName : imageName, text : text, opacity : opacity, x : pointX, y : pointY,
|
||||
width : width, count : previewCount, fontColor : fontColor, fontSize : fontSize};
|
||||
jQuery.post("setPreviewWaterMark", imageData, function() {
|
||||
var path = imageServerUrl + "/preview/" + "/previewImage" + next + ".jpg";
|
||||
jQuery('td.img-src img').attr('src', path);
|
||||
jQuery('#ImageWatermarking_previewCount').attr('value', next);
|
||||
});
|
||||
}
|
||||
function setImageDimension() {
|
||||
var productId = jQuery('#ImageWatermarking_productId').val();
|
||||
var imageName = jQuery('#ImageWatermarking_imageName').val();
|
||||
var positionX = jQuery('#ImageWatermarking_positionX').val();
|
||||
var positionY = jQuery('#ImageWatermarking_positionY').val();
|
||||
var width = jQuery('#ImageWatermarking_width').val();
|
||||
var height = jQuery('#ImageWatermarking_height').val();
|
||||
var pointX = parseFloat(positionX / width);
|
||||
var pointY = parseFloat(positionY / height);
|
||||
jQuery('#ImageWatermarking_pointX').attr('value', pointX);
|
||||
jQuery('#ImageWatermarking_pointY').attr('value', pointY);
|
||||
}
|
||||
function deletePreviewWatermarkImage() {
|
||||
var productId = jQuery('#ImageWatermarking_productId').val();
|
||||
var imageName = jQuery('#ImageWatermarking_imageName').val();
|
||||
var contentId = jQuery('#ImageFrames_contentId').val();
|
||||
var dataResourceId = jQuery('#ImageFrames_dataResourceId').val();
|
||||
var previewCount = jQuery('#ImageWatermarking_previewCount').val();
|
||||
jQuery.post("deletePreviewWatermarkImage", {productId : productId, imageName : imageName, contentId : contentId, dataResourceId : dataResourceId, count : previewCount});
|
||||
}
|
||||
</script>
|
||||
@@ -2712,11 +2712,6 @@ under the License.
|
||||
<response name="success" type="view" value="ImageFrames"/>
|
||||
<response name="error" type="view" value="ImageFrames"/>
|
||||
</request-map>
|
||||
<request-map uri="ImageWatermarking">
|
||||
<security https="true" auth="true"/>
|
||||
<response name="success" type="view" value="ImageWatermarking"/>
|
||||
<response name="error" type="view" value="ImageWatermarking"/>
|
||||
</request-map>
|
||||
<request-map uri="ImageCropping">
|
||||
<security https="true" auth="true"/>
|
||||
<response name="success" type="view" value="ImageCropping"/>
|
||||
@@ -2799,18 +2794,6 @@ under the License.
|
||||
<response name="success" type="view" value="ListImageManage"/>
|
||||
<response name="error" type="view" value="ListImageManage"/>
|
||||
</request-map>
|
||||
<request-map uri="createWatermarkImage">
|
||||
<security https="true" auth="true"/>
|
||||
<event type="java" path="org.ofbiz.product.imagemanagement.WatermarkImage" invoke="createWatermarkImage"/>
|
||||
<response name="success" type="view" value="ListImageManage"/>
|
||||
<response name="error" type="view" value="ImageWatermarking"/>
|
||||
</request-map>
|
||||
<request-map uri="previewWatermarkImage">
|
||||
<security https="true" auth="true"/>
|
||||
<event type="java" path="org.ofbiz.product.imagemanagement.WatermarkImage" invoke="previewWatermarkImage"/>
|
||||
<response name="success" type="view" value="viewPreviewImage"/>
|
||||
<response name="error" type="view" value="viewPreviewImage"/>
|
||||
</request-map>
|
||||
<request-map uri="previewFrameImage">
|
||||
<security https="true" auth="true"/>
|
||||
<event type="java" path="org.ofbiz.product.imagemanagement.FrameImage" invoke="previewFrameImage"/>
|
||||
@@ -2873,7 +2856,6 @@ under the License.
|
||||
<security https="true" auth="true"/>
|
||||
<event type="groovy" path="component://product/groovyScripts/catalog/imagemanagement/CheckAction.groovy"/>
|
||||
<response name="frame" type="request" value="ImageFrames"/>
|
||||
<response name="watermark" type="request" value="ImageWatermarking"/>
|
||||
<response name="crop" type="request" value="ImageCropping"/>
|
||||
<response name="rotate" type="request" value="ImageRotating"/>
|
||||
<response name="noAction" type="request-redirect" value="ListImageManage"/>
|
||||
@@ -2909,12 +2891,6 @@ under the License.
|
||||
<response name="success" type="view" value="ListPeopleRejected"/>
|
||||
<response name="error" type="view" value="ListPeopleRejected"/>
|
||||
</request-map>
|
||||
<request-map uri="setPreviewWaterMark">
|
||||
<security https="true" auth="true"/>
|
||||
<event type="java" path="org.ofbiz.product.imagemanagement.WatermarkImage" invoke="setPreviewWaterMark"/>
|
||||
<response name="success" type="view" value="viewPreviewImage"/>
|
||||
<response name="error" type="view" value="viewPreviewImage"/>
|
||||
</request-map>
|
||||
<request-map uri="chooseFrameImage">
|
||||
<security https="true" auth="true"/>
|
||||
<event type="java" path="org.ofbiz.product.imagemanagement.FrameImage" invoke="chooseFrameImage"/>
|
||||
@@ -2933,12 +2909,6 @@ under the License.
|
||||
<security https="true" auth="true"/>
|
||||
<response name="success" type="view" value="LookupImageFrame"/>
|
||||
</request-map>
|
||||
<request-map uri="deletePreviewWatermarkImage">
|
||||
<security https="true" auth="true"/>
|
||||
<event type="java" path="org.ofbiz.product.imagemanagement.WatermarkImage" invoke="deletePreviewWatermarkImage"/>
|
||||
<response name="success" type="view" value="ListImageManage"/>
|
||||
<response name="error" type="view" value="ImageWatermarking"/>
|
||||
</request-map>
|
||||
<request-map uri="ImageResize">
|
||||
<security https="true" auth="true"/>
|
||||
<response name="success" type="view" value="ImageResize"/>
|
||||
@@ -3274,7 +3244,6 @@ under the License.
|
||||
<view-map name="ImageApprove" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageApprove" type="screen"/>
|
||||
<view-map name="ImageRejected" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageRejected" type="screen"/>
|
||||
<view-map name="ImageFrames" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageFrames" type="screen"/>
|
||||
<view-map name="ImageWatermarking" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageWatermarking" type="screen"/>
|
||||
<view-map name="ImageCropping" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageCropping" type="screen"/>
|
||||
<view-map name="ImageRotating" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageRotating" type="screen"/>
|
||||
<view-map name="ImageShare" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageShare" type="screen"/>
|
||||
|
||||
@@ -311,7 +311,6 @@ under the License.
|
||||
document.ListImageManage.submit();">
|
||||
<drop-down allow-empty="true">
|
||||
<option key="frame" description="${uiLabelMap.ImageManagementFrame}"/>
|
||||
<option key="watermark" description="${uiLabelMap.ImageManagementWatermark}"/>
|
||||
<option key="crop" description="${uiLabelMap.ImageManagementCrop}"/>
|
||||
<option key="rotate" description="${uiLabelMap.ImageManagementRotate}"/>
|
||||
</drop-down>
|
||||
@@ -428,72 +427,7 @@ under the License.
|
||||
</hyperlink>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
<form name="ImageWatermarking" type="single" target="createWatermarkImage" title="" header-row-style="header-row" default-table-style="basic-table">
|
||||
<actions>
|
||||
<entity-one entity-name="ContentDataResourceView" value-field="contentDataResource">
|
||||
<field-map field-name="contentId" from-field="parameters.contentId"/>
|
||||
<field-map field-name="drDataResourceId" from-field="parameters.dataResourceId"/>
|
||||
</entity-one>
|
||||
<set field="imageURL" from-field="contentDataResource.drObjectInfo"/>
|
||||
</actions>
|
||||
<field name="imageServerUrl"><hidden/></field>
|
||||
<field name="productId"><hidden/></field>
|
||||
<field name="contentId"><hidden/></field>
|
||||
<field name="dataResourceId"><hidden/></field>
|
||||
<field name="pointX"><hidden/></field>
|
||||
<field name="pointY"><hidden/></field>
|
||||
<field name="width"><hidden/></field>
|
||||
<field name="height"><hidden/></field>
|
||||
<field name="positionX" widget-area-style="positionX"><hidden value="50.00"/></field>
|
||||
<field name="positionY" widget-area-style="positionY"><hidden value="50.00"/></field>
|
||||
<field name="previewCount" widget-area-style="count"><hidden value="0"/></field>
|
||||
<field name="imageName"><hidden value="${contentDataResource.drDataResourceName}"/></field>
|
||||
<field name="imageWatermark" use-when="imageURL != null" title="${uiLabelMap.CommonImage}" widget-area-style="img-src"><image value="${imageURL}"/></field>
|
||||
<field name="imageWatermark" use-when="imageURL == null" title="${uiLabelMap.CommonImage}" widget-area-style="img-src-de"><image value="/images/defaultImage.jpg"/></field>
|
||||
<field name="" widget-style="h3"><display description="${uiLabelMap.ImageManagementWatermarkingLocation}"/></field>
|
||||
<field name="imageOpacity" title="${uiLabelMap.ImageManagementOpacity}" widget-area-style="opacity">
|
||||
<drop-down no-current-selected-key="0.5">
|
||||
<option key="0.1" description="10%"/>
|
||||
<option key="0.2" description="20%"/>
|
||||
<option key="0.3" description="30%"/>
|
||||
<option key="0.4" description="40%"/>
|
||||
<option key="0.5" description="50%"/>
|
||||
<option key="0.6" description="60%"/>
|
||||
<option key="0.7" description="70%"/>
|
||||
<option key="0.8" description="80%"/>
|
||||
<option key="0.9" description="90%"/>
|
||||
<option key="1.0" description="100%"/>
|
||||
</drop-down>
|
||||
</field>
|
||||
<field name="textWatermark" title="${uiLabelMap.CommonText}" widget-area-style="watermark_txt"><text default-value="DEFAULT"/></field>
|
||||
<field name="previewButton" title=" " widget-style="buttontext" widget-area-style="preview"><hyperlink target="#" target-type="plain" description="${uiLabelMap.CommonPreview}"/></field>
|
||||
<field name="colorWatermark" title="${uiLabelMap.ImageManagementTextColor}" widget-area-style="txt_color">
|
||||
<drop-down allow-empty="true" no-current-selected-key="TEXT_BLACK">
|
||||
<entity-options entity-name="ProductFeature" key-field-name="productFeatureId">
|
||||
<entity-constraint name="productFeatureTypeId" value="COLOR"/>
|
||||
<entity-constraint name="productFeatureCategoryId" value="TEXT"/>
|
||||
<entity-order-by field-name="defaultSequenceNum"/>
|
||||
</entity-options>
|
||||
</drop-down>
|
||||
</field>
|
||||
<field name="sizeWatermark" title="${uiLabelMap.ImageManagementTextSize}" widget-area-style="txt_size">
|
||||
<drop-down allow-empty="true" no-current-selected-key="TEXT_MIDDLE">
|
||||
<entity-options entity-name="ProductFeature" key-field-name="productFeatureId">
|
||||
<entity-constraint name="productFeatureTypeId" value="SIZE"/>
|
||||
<entity-constraint name="productFeatureCategoryId" value="TEXT"/>
|
||||
<entity-order-by field-name="defaultSequenceNum"/>
|
||||
</entity-options>
|
||||
</drop-down>
|
||||
</field>
|
||||
<field name="submitButton" title="${uiLabelMap.CommonSubmit}" event="onClick" action="javascript:setImageDimension()" widget-style="smallSubmit" ><submit button-type="button"/></field>
|
||||
<field name="cancelButton" title=" " widget-style="buttontext" event="onClick" action="javascript:deletePreviewWatermarkImage();">
|
||||
<hyperlink target="ListImageManage" description="${uiLabelMap.CommonCancel}">
|
||||
<parameter param-name="productId" from-field="parameters.productId"/>
|
||||
</hyperlink>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
|
||||
<form name="ImageCropping" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="CropImage">
|
||||
<actions>
|
||||
<entity-one entity-name="ContentDataResourceView" value-field="contentDataResource">
|
||||
|
||||
@@ -511,45 +511,7 @@ under the License.
|
||||
</widgets>
|
||||
</section>
|
||||
</screen>
|
||||
|
||||
<screen name="ImageWatermarking">
|
||||
<section>
|
||||
<actions>
|
||||
<set field="userTabButtonImage" value="ImageManage"/>
|
||||
<set field="currentFormName" value="ImageWatermarking"/>
|
||||
<set field="statusForm" value="IM_PENDING"/>
|
||||
<entity-one entity-name="ContentDataResourceView" value-field="contentDataResource">
|
||||
<field-map field-name="contentId" from-field="parameters.contentId"/>
|
||||
<field-map field-name="drDataResourceId" from-field="parameters.dataResourceId"/>
|
||||
</entity-one>
|
||||
<set field="imageURL" from-field="contentDataResource.drObjectInfo"/>
|
||||
<property-to-field resource="catalog" property="image.management.url" field="imageServerUrl"/>
|
||||
</actions>
|
||||
<widgets>
|
||||
<decorator-screen name="ImageManagementDecorator" location="${parameters.mainDecoratorLocation}">
|
||||
<decorator-section name="body">
|
||||
<section>
|
||||
<condition>
|
||||
<if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/>
|
||||
</condition>
|
||||
<widgets>
|
||||
<screenlet title="${uiLabelMap.ImageManagementImageWatermarking}">
|
||||
<include-form name="ImageWatermarking" location="component://product/widget/catalog/ImageManagementForms.xml"/>
|
||||
<platform-specific>
|
||||
<html><html-template location="component://product/template/imagemanagement/ImageWatermark.ftl"/></html>
|
||||
</platform-specific>
|
||||
</screenlet>
|
||||
</widgets>
|
||||
<fail-widgets>
|
||||
<label text="You do not have permission to access this page. ("IMAGE_MANAGEMENT_ADMIN" needed)"/>
|
||||
</fail-widgets>
|
||||
</section>
|
||||
</decorator-section>
|
||||
</decorator-screen>
|
||||
</widgets>
|
||||
</section>
|
||||
</screen>
|
||||
|
||||
|
||||
<screen name="ImageCropping">
|
||||
<section>
|
||||
<actions>
|
||||
|
||||
Reference in New Issue
Block a user