Linux:修订间差异

跳转到导航 跳转到搜索
无编辑摘要
无编辑摘要
第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 是压缩


== 其他 ==
== 其他 ==