In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
< origHeight) { // 以宽为标准 s = getSize(origWidth, origHeight, width, height, 1); } else {// 以高为标准 s = getSize(origWidth, origHeight, width, height, 2); } if (thumbnail(src, dst, s[0], s[1])) { return crop(src, dst, width, height, left, top); } return false; } /** * 加边框。 * @param src 源图片 * @param dst 目标图片 * @param borderWidth 边框的宽度 * @param borderHeight 边框的高度 * @param borderColor 边框的颜色 * @return 是否处理成功 */ public static boolean border(String src, String dst, int borderWidth, int borderHeight, String borderColor) { // 构建命令 CommandLine cmdLine = new CommandLine(EXECUTABLE_CONVERT); cmdLine.addArgument("-bordercolor"); cmdLine.addArgument(borderColor); cmdLine.addArgument("-border"); cmdLine.addArgument(borderWidth + "x" + borderHeight); cmdLine.addArgument(src); cmdLine.addArgument(dst); try { executeCommandLine(cmdLine); return true; } catch (Exception e) { LOG.error("加图片边框时发生异常,Cause: ", e); return false; } } /** * 转换图片格式。 * @param src 源图片 * @param dst 目标图片 * @param format 转换的格式 * @return 是否处理成功 */ public static boolean format(String src, String dst, String format) { // 构建命令 CommandLine cmdLine = new CommandLine(EXECUTABLE_CONVERT); cmdLine.addArgument(src); cmdLine.addArgument("-format"); cmdLine.addArgument("'" + format + "'"); cmdLine.addArgument(dst); try { executeCommandLine(cmdLine); return true; } catch (Exception e) { LOG.error("转换图片格式时发生异常,Cause: ", e); return false; } } /** * 转换无限极的TIFF图片。 */ public static boolean convertTiff(String src, String dst) { // 构建命令 CommandLine cmdLine = new CommandLine(EXECUTABLE_CONVERT); cmdLine.addArgument(src); cmdLine.addArgument("-colorspace"); cmdLine.addArgument("RGB"); cmdLine.addArgument(dst); try { executeCommandLine(cmdLine); return true; } catch (Exception e) { LOG.error("转换图片格式时发生异常,Cause: ", e); return false; } } /** * 获得要压缩图片的大小。 * @param w 图片的原宽度 * @param h 图片的原高度 * @param width 标准宽 * @param height 标准高 * @param type 类型 1-以宽为标准压缩 2-以高为标准压缩 3-以比例大小压缩 * @return size[0]-要压缩的宽度, size[1]-要压缩的高度 */ public static int[] getSize(double w, double h, double width, double height, int type) { if (w < width) {// 如果原宽度比标准宽度小 width = w; } if (h < height) {// 如果原高度比标准高度小 height = h; } double scale = w / h; switch (type) { case 1: height = width / scale; break; case 2: width = height * scale; break; case 3: if (width / height >Scale) {width = height * scale;} else if ((width / height) < scale) {height = width / scale;} break;} int [] size = new int [2]; size [0] = (int) width; size [1] = (int) height; return size;} / * * specify the width. * @ param src * @ param width * @ param dst * / public static boolean resize (String src, int width, String dst) {/ / build commands CommandLine cmdLine = new CommandLine (EXECUTABLE_CONVERT); cmdLine.addArgument (src); cmdLine.addArgument ("- resize"); cmdLine.addArgument (width + "); cmdLine.addArgument (dst); try {executeCommandLine (cmdLine); return true } catch (Exception e) {LOG.error ("exception occurred while thumbnail picture, Cause:", e); return false;}} / * specify width and height. * @ param src * @ param width * @ param dst * / public static boolean resizeWH (String src,String dst, int width, int height) {/ / build commands CommandLine cmdLine = new CommandLine (EXECUTABLE_CONVERT); cmdLine.addArgument (src); cmdLine.addArgument ("- resize"); cmdLine.addArgument (width + "x" + height + "!"); cmdLine.addArgument (dst); try {executeCommandLine (cmdLine); return true } catch (Exception e) {LOG.error ("exception occurred while thumbnail picture, Cause:", e); return false;}
Imagemagick is to be installed on the server.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.