更改
跳到导航
跳到搜索
←上一编辑
下一编辑→
Linux
(查看源代码)
2019年8月23日 (五) 15:10的版本
添加839字节
、
2019年8月23日 (五) 15:10
无编辑摘要
第14行:
第14行:
** 413 Request Entity Too Large
** 413 Request Entity Too Large
**: <code>client_max_body_size 8m;</code>
**: <code>client_max_body_size 8m;</code>
+
+
== 图片压缩 ==
+
使用imagemagick进行图片压缩
+
首先安装apt install imagemagick
+
+
下面是demo,把再当前路径下的public目录中的图片进行压缩:
+
<nowiki>
+
import os
+
+
arr = [
+
'/upload/images/c0d0d881b2d742165999d91ec6380de2.jpg',
+
'/upload/images/4e16982954bcbe89667ec70f67c02f20.jpg',
+
]
+
+
for i in arr:
+
try:
+
# print i
+
kb = os.path.getsize('./public%s' % i)
+
newNames = os.path.splitext(i)
+
strname = '%s_s%s' % newNames
+
if kb/1024 > 1:
+
shell = "convert -sample 30%%x30%% ./public%s ./public%s" % (i, strname)
+
os.system(shell)
+
# print "update themes set preview='%s' where preview='%s';" % (strname, i)
+
except Exception,e :
+
print e
+
pass
+
+
</nowiki>
+
-resize 是缩小,-sample 是压缩
== 其他 ==
== 其他 ==
Yaosong
行政员
、
界面管理员
、
管理员
133
个编辑
导航菜单
个人工具
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
工具
特殊页面
可打印版本