diff --git a/JSD-8472-需求确认书V1.docx b/JSD-8472-需求确认书V1.docx
new file mode 100644
index 0000000..2f3bd6e
Binary files /dev/null and b/JSD-8472-需求确认书V1.docx differ
diff --git a/README.md b/README.md
index 909356f..5808791 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
# open-JSD-8472
-JSD-8472 图片压缩函数
\ No newline at end of file
+JSD-8472 图片压缩函数\
+免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
+仅作为开发者学习参考使用!禁止用于任何商业用途!\
+为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。
\ No newline at end of file
diff --git a/lib/finekit-10.0.jar b/lib/finekit-10.0.jar
new file mode 100644
index 0000000..546f2f5
Binary files /dev/null and b/lib/finekit-10.0.jar differ
diff --git a/lib/thumbnailator-0.4.14.jar b/lib/thumbnailator-0.4.14.jar
new file mode 100644
index 0000000..040cecd
Binary files /dev/null and b/lib/thumbnailator-0.4.14.jar differ
diff --git a/plugin.xml b/plugin.xml
new file mode 100644
index 0000000..24430b6
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,18 @@
+
+ com.fr.plugin.third.party.jsdiehc
+
+ yes
+ 0.2
+ 10.0
+ 2019-01-01
+ fr.open
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/third/party/jsdiehc/function/ImageAttachment.java b/src/main/java/com/fr/plugin/third/party/jsdiehc/function/ImageAttachment.java
new file mode 100644
index 0000000..a47140b
--- /dev/null
+++ b/src/main/java/com/fr/plugin/third/party/jsdiehc/function/ImageAttachment.java
@@ -0,0 +1,43 @@
+package com.fr.plugin.third.party.jsdiehc.function;
+
+import com.fr.cache.Attachment;
+import com.fr.cache.AttachmentFileBase;
+import com.fr.cache.type.AttachmentScope;
+
+public class ImageAttachment extends Attachment {
+ public ImageAttachment()
+ {
+ super("", "", "", null);
+ }
+
+ private byte[] imageBytes;
+
+ public ImageAttachment(String s, String s1, String s2, AttachmentFileBase attachmentFileBase, int i, int i1, AttachmentScope attachmentScope) {
+ super(s, s1, s2, attachmentFileBase, i, i1, attachmentScope);
+ }
+
+ public ImageAttachment(String s, String s1, String s2, AttachmentFileBase attachmentFileBase, int i, int i1) {
+ super(s, s1, s2, attachmentFileBase, i, i1);
+ }
+
+ public ImageAttachment(String s, String s1, String s2, AttachmentFileBase attachmentFileBase, AttachmentScope attachmentScope) {
+ super(s, s1, s2, attachmentFileBase, attachmentScope);
+ }
+
+ public ImageAttachment(String s, String s1, String s2, AttachmentFileBase attachmentFileBase) {
+ super(s, s1, s2, attachmentFileBase);
+ }
+
+
+ public byte[] getBytes() {
+ return this.imageBytes;
+ }
+
+ public byte[] getImageBytes() {
+ return imageBytes;
+ }
+
+ public void setImageBytes(byte[] bytes) {
+ this.imageBytes = bytes;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/third/party/jsdiehc/function/ImageCompressionScaleFunction.java b/src/main/java/com/fr/plugin/third/party/jsdiehc/function/ImageCompressionScaleFunction.java
new file mode 100644
index 0000000..562c335
--- /dev/null
+++ b/src/main/java/com/fr/plugin/third/party/jsdiehc/function/ImageCompressionScaleFunction.java
@@ -0,0 +1,113 @@
+package com.fr.plugin.third.party.jsdiehc.function;
+
+import com.fanruan.api.log.LogKit;
+import com.fanruan.api.util.StringKit;
+import com.fr.cache.Attachment;
+import com.fr.general.FArray;
+import com.fr.intelli.record.Focus;
+import com.fr.intelli.record.Original;
+import com.fr.plugin.context.PluginContexts;
+import com.fr.record.analyzer.EnableMetrics;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.Primitive;
+import com.fr.stable.fun.Authorize;
+import net.coobird.thumbnailator.Thumbnails;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+
+/**
+ * 图片压缩缩放函数
+ * IMAGE_COMPRESSION_SCALE(image, [quality], [scale])
+ * 参数:
+ * image:图片对象
+ * quality:压缩质量
+ * scale:缩放比例
+ */
+@Authorize(callSignKey = "com.fr.plugin.third.party.jsdiehc")
+@EnableMetrics
+public class ImageCompressionScaleFunction extends AbstractFunction {
+
+ @Focus(id = "com.fr.plugin.third.party.jsdiehc", text = "plugin-jsdiehc", source = Original.PLUGIN)
+ public Object run(Object[] args) {
+ if (!PluginContexts.currentContext().isAvailable()) {
+ LogKit.error("图片压缩函数许可证过期");
+ return Primitive.ERROR_VALUE;
+ }
+
+ if ((args == null) || (args.length <= 0)) {
+ return Primitive.ERROR_VALUE;
+ }
+
+ if (args.length <= 1) {
+ return args;
+ }
+ Object obj = args[0];
+ if (obj == null) {
+ return Primitive.ERROR_VALUE;
+ }
+
+ Object obj1 = args[1];
+ if (obj1 == null) {
+ return Primitive.ERROR_VALUE;
+ }
+
+ try {
+ float quality = Float.valueOf(String.valueOf(obj1));
+ if (!(obj instanceof FArray)) {
+ return compressImage(obj, quality);
+ }
+
+ FArray objArray = (FArray) obj;
+ FArray newArray = new FArray();
+ if (objArray.length() <= 0) {
+ return obj;
+ }
+ Object tempObj, compressObj;
+ for (int i = 0, max = objArray.length() - 1; i <= max; i++) {
+ tempObj = objArray.elementAt(i);
+ compressObj = compressImage(tempObj, quality);
+ newArray.add(compressObj);
+ }
+ return newArray;
+ } catch (Exception e) {
+ LogKit.error("jsdiehc图片压缩函数出错," + e.getMessage(), e);
+ return Primitive.ERROR_VALUE;
+ }
+ }
+
+ private Object compressImage(Object obj, float quality) throws IOException {
+ if (obj == null) {
+ return null;
+ }
+
+ if ((quality < 0) || (quality >= 1)) {
+ quality = 1;
+ }
+
+ if (obj instanceof BufferedImage) {
+ BufferedImage inputBufferedImage = (BufferedImage) obj;
+ BufferedImage outBufferedImage = Thumbnails.of(inputBufferedImage).scale(1).outputQuality(quality).asBufferedImage();
+ return outBufferedImage;
+ }
+
+ if (!(obj instanceof Attachment)) {
+ return obj;
+ }
+ Attachment attachment = (Attachment) obj;
+ if (!StringKit.equalsIgnoreCase(attachment.getType(), "image")) {
+ return obj;
+ }
+
+ InputStream inputStream = attachment.getInputStream();
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ Thumbnails.of(inputStream).scale(1).outputQuality(quality).toOutputStream(outputStream);
+ ImageAttachment imageAttachment = new ImageAttachment();
+ imageAttachment.setImageBytes(outputStream.toByteArray());
+ return imageAttachment;
+ }
+
+}
diff --git a/图片压缩函数使用手册.docx b/图片压缩函数使用手册.docx
new file mode 100644
index 0000000..3a22292
Binary files /dev/null and b/图片压缩函数使用手册.docx differ