- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章Nginx代理输出缩放图片的方法由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
本文实例为大家分享了Nginx代理输出缩放图片的具体代码,供大家参考,具体内容如下 。
nginx 配置文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# document ppt convert Configuration.
upstream document.polyv.net {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name document.polyv.net;
index index.html index.htm;
charset utf-8;
client_max_body_size 1000m;
# ignore favicon.ico not exist.
location = /favicon.ico {
log_not_found off;
access_log off;
}
# not allow to visit hidden files.
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location / {
if
($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$) {
add_header Content-Disposition:
'attachment;'
;
add_header Content-Type:
'APPLICATION/OCTET-STREAM'
;
}
proxy_pass http:
//document.polyv.net;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REQUEST_HOST $host;
# include proxy.conf;
charset UTF-8;
}
# user upload files
location /images/ {
#expires 7d;
alias /data03/ovp/blobs/;
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_set_header Accept-Encoding
""
;
if
( !-f $request_filename ) {
proxy_pass http:
//document.polyv.net;
}
}
location /blobs/ {
#expires 7d;
alias /data03/ovp/blobs/;
}
location /preview/images/ {
#expires 7d;
alias /data03/ovp/blobs/;
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_set_header Accept-Encoding
""
;
if
( !-f $request_filename ) {
proxy_pass http:
//document.polyv.net;
}
}
}
|
代理输出缩放图片 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
package
com.document.handle.controller;
import
java.io.BufferedInputStream;
import
java.io.File;
import
java.io.IOException;
import
java.io.OutputStream;
import
java.net.HttpURLConnection;
import
java.net.URL;
import
javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse;
import
org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger;
import
org.slf4j.LoggerFactory;
import
org.springframework.stereotype.Controller;
import
org.springframework.web.bind.ServletRequestUtils;
import
org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestMapping;
import
com.document.tool.ImageMagickUtils;
import
com.document.tool.SystemConfig;
@Controller
public
class
ImageAgentController {
private
static
final
Logger LOG = LoggerFactory.getLogger(ImageAgentController.
class
);
/**
* ppt预览图片代理输出
* @throws IOException
*/
@RequestMapping
(
"/preview/images/{year}/{month}/{md5id}/{preview}/{filename}.{ext}"
)
public
void
cropImage(
@PathVariable
String year,
@PathVariable
String month,
@PathVariable
String md5id,
@PathVariable
String preview,
@PathVariable
String filename,
@PathVariable
String ext,
HttpServletRequest request, HttpServletResponse response)
throws
IOException {
// String rootDir = "/data03/ovp/blobs/";
String rootDir = SystemConfig.getBlobDirectory();
String oname = filename.substring(
1
, filename.length());
// 原图文件名
String dirString = rootDir + year +
"/"
+ month +
"/"
+ md5id +
"/"
+ oname +
"."
+ ext;
String targetFileString = rootDir + year +
"/"
+ month +
"/"
+ md5id +
"/preview/"
+ filename +
"."
+ ext;
//如果原图存在
File originImage =
new
File(oname);
if
(originImage.exists()){
LOG.info(
"corpImage..."
+ dirString +
" -> "
+ targetFileString);
File newfile =
new
File(targetFileString);
String pathString = newfile.getParent();
LOG.info(
"pathString...{} {}"
, pathString);
File pathFile =
new
File(pathString);
if
(!pathFile.exists()) {
LOG.info(
"---create file---"
);
pathFile.mkdirs();
}
boolean
status = ImageMagickUtils.scale(dirString, targetFileString,
240
,
180
);
if
(status) {
response.reset();
response.setContentType(
"image/"
+ ext);
java.io.InputStream in =
new
java.io.FileInputStream(targetFileString);
// FilenameUrlUtils.getImageFilename(targetFileString);
if
(in !=
null
) {
byte
[] b =
new
byte
[
1024
];
int
len;
while
((len = in.read(b)) != -
1
) {
response.getOutputStream().write(b);
}
in.close();
}
}
}
else
{
LOG.info(
"原图目录不存在-preview:{}"
,dirString);
}
}
/**
* ppt固定尺寸图片代理输出
* @throws IOException
* http://document.polyv.net/images/2016/03/de37d2ceb11ac068c18c5e4428541075/jpg-3/1000x540.png
*
* http://document.polyv.net/images/2016/03/de37d2ceb11ac068c18c5e4428541075/jpg-3.png
*/
@RequestMapping
(
"/images/{year}/{month}/{md5id}/{filename}/{width}x{height}.{ext}"
)
public
void
cropfixedImage(
@PathVariable
String year,
@PathVariable
String month,
@PathVariable
String md5id,
@PathVariable
String filename,
@PathVariable
Integer width,
@PathVariable
Integer height,
@PathVariable
String ext,
HttpServletRequest request, HttpServletResponse response)
throws
IOException {
// String rootDir = "/data03/ovp/blobs/";
String rootDir = SystemConfig.getBlobDirectory();
//String oname = filename.substring(1, filename.length());// 原图文件名
String dirString = rootDir + year +
"/"
+ month +
"/"
+ md5id +
"/"
+ ( filename +
"."
+ ext);
String targetFileString = rootDir + year +
"/"
+ month +
"/"
+ md5id +
"/"
+ filename +
"/"
+ (width +
"x"
+ height +
"."
+ ext);
//如果原图存在
File originImage =
new
File(dirString);
if
(originImage.exists()){
File targetFileStringFile =
new
File(targetFileString);
if
(!targetFileStringFile.exists()){
LOG.info(
"corpImage..."
+ dirString +
" -> "
+ targetFileString);
File newfile =
new
File(targetFileString);
String pathString = newfile.getParent();
LOG.info(
"pathString...{} {}"
, pathString);
File pathFile =
new
File(pathString);
if
(!pathFile.exists()) {
LOG.info(
"---create file---"
);
pathFile.mkdirs();
}
ImageMagickUtils.resizeWH(dirString, targetFileString,width,height);
}
response.setContentType(
"image/"
+ ext);
java.io.InputStream in =
null
;
try
{
in =
new
java.io.FileInputStream(targetFileString);
response.setContentLength(in.available());
byte
[] buffer =
new
byte
[
1024
];
int
count =
0
;
while
((count = in.read(buffer)) >
0
) {
response.getOutputStream().write(buffer,
0
, count);
}
response.flushBuffer();
}
catch
(Exception e){
e.printStackTrace();
}
finally
{
try
{
in.close();
}
catch
(Exception e) {
}
}
}
else
{
LOG.info(
"原图目录不存在:{}"
,dirString);
}
}
/**
* 图片下载
*/
@RequestMapping
(
"get/image/data"
)
public
void
downloadImage(HttpServletRequest request, HttpServletResponse response)
throws
IOException {
String filePath = ServletRequestUtils.getStringParameter(request,
"filePath"
,
""
);
//图片访问路劲
String fileName = ServletRequestUtils.getStringParameter(request,
"fileName"
,
""
);
//名称
if
(StringUtils.isNotBlank(filePath) || StringUtils.isNotBlank(fileName)){
String destUrl = filePath;
//LOG.info("--------------"+filePath);
String fileFormat=filePath.substring(filePath.lastIndexOf(
"."
));
//String name=fileName.trim()+fileFormat;
String name=filePath.substring(filePath.lastIndexOf(
"/"
)+
1
, filePath.length());
//File f = new File(filePath);
//response.setHeader("Content-Disposition", "attachment; filename="+java.net.URLEncoder.encode(f.getName(),"UTF-8"));
//LOG.info("--------------"+f.getName());
// 建立链接
URL url =
new
URL(destUrl);
HttpURLConnection httpUrl = (HttpURLConnection) url.openConnection();
// 连接指定的资源
httpUrl.connect();
// 获取网络输入流
BufferedInputStream bis =
new
BufferedInputStream(httpUrl.getInputStream());
Integer lenf=httpUrl.getContentLength();
//String lenf=this.getFileLength(4189053, 7189053);
response.setContentType(
"application/x-msdownload"
);
response.setHeader(
"Content-Length"
, lenf.toString());
//文件大小值5几M
response.setHeader(
"Content-Disposition"
,
"attachment; filename="
+java.net.URLEncoder.encode(name,
"UTF-8"
));
OutputStream out = response.getOutputStream();
byte
[] buf =
new
byte
[
1024
];
if
(destUrl !=
null
) {
BufferedInputStream br = bis;
int
len =
0
;
while
((len = br.read(buf)) >
0
){
out.write(buf,
0
, len);
}
br.close();
}
out.flush();
out.close();
}
}
}
|
图片缩放的业务 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
package
com.document.tool;
import
java.io.IOException;
import
javax.swing.ImageIcon;
import
org.apache.commons.exec.CommandLine;
import
org.apache.commons.exec.DefaultExecuteResultHandler;
import
org.apache.commons.exec.DefaultExecutor;
import
org.apache.commons.exec.ExecuteException;
import
org.apache.commons.exec.ExecuteWatchdog;
import
org.apache.commons.exec.Executor;
import
org.slf4j.Logger;
import
org.slf4j.LoggerFactory;
/**
* 使用ImageMagick对图片文件进行处理的工具类。
* @author XingNing OU
*/
public
abstract
class
ImageMagickUtils {
private
static
final
String EXECUTABLE_CONVERT =
"/usr/bin/convert"
;
// convert命令
private
static
final
String EXECUTABLE_COMPOSITE =
"/usr/bin/composite"
;
// composite命令
private
static
final
long
EXECUTE_TIMEOUT =
30
*
60
* 1000L;
// 30 minutes
private
static
final
Logger LOG = LoggerFactory.getLogger(ImageMagickUtils.
class
);
/**
* 执行图片处理的命令。
* @param cmdLine 待执行的命令
* @return exitValue,一般等于0时表示正常运行结束
* @throws ExecuteException 命令执行失败时抛出此异常
* @throws IOException 当发生IO错误时抛出此异常
* @throws InterruptedException 当等待异步返回结果被中断时抛出此异常
*/
public
static
int
executeCommandLine(CommandLine cmdLine)
throws
ExecuteException, IOException,
InterruptedException {
Executor executor =
new
DefaultExecutor();
executor.setExitValue(
0
);
// Kill a run-away process after EXECUTE_TIME milliseconds.
ExecuteWatchdog watchdog =
new
ExecuteWatchdog(EXECUTE_TIMEOUT);
executor.setWatchdog(watchdog);
// Execute the print job asynchronously.
DefaultExecuteResultHandler resultHandler =
new
DefaultExecuteResultHandler();
executor.execute(cmdLine, resultHandler);
// Some time later the result handler callback was invoked.
resultHandler.waitFor();
// So we can safely request the exit value.
return
resultHandler.getExitValue();
}
/**
* 按照高宽比例缩小图片。
* @param src 源图片
* @param dst 目标图片
* @param width 图片图片的宽度
* @param height 目标图片的高度
* @return 是否处理成功
*/
public
static
boolean
scale(String src, String dst,
int
width,
int
height) {
// 构建命令
CommandLine cmdLine =
new
CommandLine(EXECUTABLE_CONVERT);
cmdLine.addArgument(src);
cmdLine.addArgument(
"-scale"
);
cmdLine.addArgument(width +
"x"
+ height);
cmdLine.addArgument(dst);
try
{
executeCommandLine(cmdLine);
return
true
;
}
catch
(Exception e) {
LOG.error(
"缩略图片时发生异常,Cause: "
, e);
return
false
;
}
}
/**
* 按照高宽比例缩小图片。
* @param src 源图片
* @param dst 目标图片
* @param width 图片图片的宽度
* @param height 目标图片的高度
* @return 是否处理成功
*/
public
static
boolean
thumbnail(String src, String dst,
int
width,
int
height) {
// 构建命令
CommandLine cmdLine =
new
CommandLine(EXECUTABLE_CONVERT);
cmdLine.addArgument(src);
cmdLine.addArgument(
"-thumbnail"
);
cmdLine.addArgument(width +
"x"
+ height);
cmdLine.addArgument(dst);
try
{
executeCommandLine(cmdLine);
return
true
;
}
catch
(Exception e) {
LOG.error(
"缩略图片时发生异常,Cause: "
, e);
return
false
;
}
}
/**
* 添加图片水印。
* @param src 源图片
* @param dst 目标图片
* @param logofile 水印图片
* @param dissolve 和水印的融合度,0-100的数字
* @param gravity 叠放方向,East,West,North,South,NorthEast,NorthWest,SouthEast,SouthWest
* @return 是否处理成功
*/
public
static
boolean
drawLogo(String src, String dst, String logofile,
int
dissolve, String gravity) {
// 构建命令
CommandLine cmdLine =
new
CommandLine(EXECUTABLE_COMPOSITE);
cmdLine.addArgument(
"-dissolve"
);
cmdLine.addArgument(dissolve +
"%"
);
cmdLine.addArgument(
"-gravity"
);
cmdLine.addArgument(gravity);
cmdLine.addArgument(logofile);
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 logofile 水印图片
* @param dissolve 和水印的融合度,0-100的数字
* @param x 水印距离左下角的距离
* @param y 水印距离右下角的距离
* @return 是否处理成功
*/
public
static
boolean
drawLogo(String src, String dst, String logofile,
int
dissolve,
int
x,
int
y) {
ImageIcon icon =
new
ImageIcon(src);
int
width = icon.getIconWidth();
// 源图的宽
int
height = icon.getIconHeight();
// 源图的高
String _x = String.valueOf(width - x);
// 在x轴上水印图片的左上顶点距离图片左上角的距离
String _y = String.valueOf(height - y);
// 在y轴上水印图片的左上顶点距离图片左上角的距离
// 构建命令
CommandLine cmdLine =
new
CommandLine(EXECUTABLE_COMPOSITE);
cmdLine.addArgument(
"-dissolve"
);
cmdLine.addArgument(dissolve +
"%"
);
cmdLine.addArgument(
"-geometry"
);
cmdLine.addArgument(_x +
"+"
+ _y);
cmdLine.addArgument(logofile);
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 width 目标宽度
* @param height 目标高度
* @param left 裁剪位置:距离左边的像素
* @param top 裁剪位置:距离上边的像素
* @return 是否处理成功
*/
public
static
boolean
crop(String src, String dst,
int
width,
int
height,
int
left,
int
top) {
// 构建命令
CommandLine cmdLine =
new
CommandLine(EXECUTABLE_CONVERT);
cmdLine.addArgument(src);
cmdLine.addArgument(
"-crop"
);
cmdLine.addArgument(width +
"x"
+ height +
"+"
+ left +
"+"
+ top);
cmdLine.addArgument(dst);
try
{
executeCommandLine(cmdLine);
return
true
;
}
catch
(Exception e) {
LOG.error(
"裁剪图片时发生异常,Cause: "
, e);
return
false
;
}
}
/**
* 获取矩形的小图。
* @param src 源图片
* @param dst 目标图片
* @param width 目标宽度
* @param height 目标高度
* @param left 裁剪位置:距离左边的像素
* @param top 裁剪位置:距离上边的像素
* @return 是否处理成功
*/
public
static
boolean
cropRect(String src, String dst,
int
width,
int
height,
int
left,
int
top) {
ImageIcon icon =
new
ImageIcon(src);
int
origWidth = icon.getIconWidth();
int
origHeight = icon.getIconHeight();
int
[] s =
new
int
[
2
];
if
(origWidth < 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;
}
/**
* 指定宽度。
* @param src
* @param width
* @param dst
*/
public
static
boolean
resize(String src,
int
width, String dst) {
// 构建命令
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(
"缩略图片时发生异常,Cause: "
, e);
return
false
;
}
}
/**
* 指定宽度、高度。
* @param src
* @param width
* @param dst
*/
public
static
boolean
resizeWH(String src,String dst,
int
width,
int
height ) {
// 构建命令
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(
"缩略图片时发生异常,Cause: "
, e);
return
false
;
}
}
}
|
服务器上要安装imagemagick.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
最后此篇关于Nginx代理输出缩放图片的方法的文章就讲到这里了,如果你想了解更多关于Nginx代理输出缩放图片的方法的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我有一个无所事事的盒子,已经运行了一段时间,今天,由于某种原因,当我尝试重新启动nginx时,得到了以下提示。 nginx: [emerg] host not found in upstream "w
我注意到,当我使用 ubuntu 命令“nginx”启动 nginx 并执行 systemctl status nginx 时。它表明 systemctl 已禁用。此外,如果我首先使用命令 syste
我的 nginx 配置如下: proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $re
周围有两个配置文件,/etc/nginx/conf.d/default.conf和 /etc/nginx/nginx.conf,但是启用了哪一个呢?我运行的是 CentOS6.4 和 nginx/1.
我的 Nginx 配置仅适用于根位置,所有其他位置都返回“Cannot GET {location}”,其中位置是域后地址的其余部分。 这是我的/etc/nginx/sites-enabled/def
我在 nginx 中为 node.js 服务器设置了反向代理。 server { listen 80; server_name sub.domain.tld; location
我的应用程序将在两个位置提供静态文件,一个是/my/path/project/static,另一个是/my/path/project/jsutils/static。 我很难让网络服务器在两个目录中查找
我的域名注册商的 DNS 访问我的服务器并获取 nginx 默认页面,因此配置正确 我复制了一个当前正在工作的 nginx 虚拟主机,更改了 server_name和 conf 文件的名称,仅此而已。
这个问题在这里已经有了答案: Can't login in to phpPgAdmin (2 个回答) 3年前关闭。 我在centos中遇到了phpPgAdmin登录的奇怪问题,我做了所有需要的事情
我要为PoC进行的操作是向来自动态后端服务器的网页添加href。使用“ subs_filter”可以很容易地添加href,但是我需要使用响应中嵌入的信息来构造href。 是否可以使用LUA处理来自pr
我有网站服务器,它有两个代理(鱿鱼,CF),它们使用不同的 header 来获取真实的 ip。 我猜 nginx 命令 set_real_ip_from ;real_ip_header X-Forwa
在控制台显示如下: Job for nginx.service failed because the control process exited witherror code. See "syste
我有一个问题,我怀疑是 NGINX 问题。基本上,当我尝试登录到我创建的网站时,出现以下错误…… 您要查找的页面暂时不可用。请稍后再试。 有没有人以前遇到过这个? 最佳答案 如果 NGINX 虚拟主机
这是我的 nginx 配置文件: server { listen 80; server_name localhost; location / {
在我的/etc/nginx/nginx.conf 文件中,我有配置。作为:- user nginx; worker_processes 1; error_log /var/log/nginx/e
有谁知道nginx支持软退出吗?这意味着它会一直运行直到所有连接都消失或超时(超过特定时间间隔)并且在此期间也不允许新连接吗? 例如: nginx stop nginx running (2 conn
有没有办法将 Nginx 配置为类似这样的直接服务器返回 (DSR) 负载平衡器: http://blog.haproxy.com/2011/07/29/layer-4-load-balancing-
我通过 apt-get 安装了 Nginx不久前在 Debian 上,我有几个网站在上面。现在我需要安装一些额外的模块,因为我不想搞砸任何事情,所以我想在执行之前仔细检查我的过程。希望这也能帮助其他不
我知道 Apache 的 pagespeed 模块可以使页面访问更快,所以,我想知道 Nginx 是否有等效的模块? 提前致谢! 最佳答案 https://github.com/pagespeed/n
如何将worker_rlimit_nofile设置为一个更大的数字,它可以是或建议最大为多少? 我正在尝试遵循以下建议: 大多数人遇到的第二个最大限制是 与您的操作系统有关。打开一个shell,su给
我是一名优秀的程序员,十分优秀!