当前位置: 首页 > news >正文

南昌网站seo网站总是跳转

南昌网站seo,网站总是跳转,域名注册了是永久的吗,wordpress中标签Python1-Pillow库简单使用 1.安装pillow2.打开和显示图像3.图像基本操作4.批量图像格式转换 save5.批量创建缩略图 thumbnail6.批量图像加文字、图片水印 blend composite7.批量调整图像大小resize 1.安装pillow # pip安装或者conda安装 conda install pillow2.打开和显示图像… Python1-Pillow库简单使用 1.安装pillow2.打开和显示图像3.图像基本操作4.批量图像格式转换 save5.批量创建缩略图 thumbnail6.批量图像加文字、图片水印 blend composite7.批量调整图像大小resize 1.安装pillow # pip安装或者conda安装 conda install pillow2.打开和显示图像 PILPython Image Library import PIL from PIL import Imageimg PIL.Image.open(lena.png) # img.show()print(img.format, img.size, img.mode) # PNG (512, 512) RGBA img PIL.Image.open(lena_c.bmp) print(img.format, img.size, img.mode) # BMP (512, 512) RGB3.图像基本操作 copy()方法用于拷贝图像、crop()方法用于裁剪图像、paste()方法用于将一个图像粘贴覆盖在另一个图像上面、resize()用于调整图像大小、rotate()用于旋转和翻转、filter()用于图像过滤。 更多文档参考pillow.readthedocs.org 使用PIL.Image模块中的new()可以创建一个给定模式和大小的新图像对象。例如创建一个新的大小为800x600的RGB图像 img PIL.Image.new(RGB, (800, 600))下面图像基本操作的实例把一幅图像的4个副本排成2x2网格左上角是原始图像右上、左下、右下方分别使用模块PIL.ImageFilter种定义的内置过滤器CONTOUR、EMBOSS、FIND_EDGES进行过滤。 import PIL from PIL import Image from PIL import ImageFilterimg PIL.Image.open(lena_c.bmp) print(img.format, img.size, img.mode) # BMP (512, 512) RGB width, height img.size# 创建新图像大小为原始图像的4倍 res PIL.Image.new(img.mode, (2*width, 2*height))# 把原始图像放在左上 res.paste(img, (0, 0, width, height))# 把轮廓过滤CONTOUR的图像放置在右上 contour img.filter(PIL.ImageFilter.CONTOUR) res.paste(contour, (width, 0, 2*width, height))# 把浮雕过滤EMBOSS的图像放置在坐下 emboss img.filter(PIL.ImageFilter.EMBOSS) res.paste(emboss, (0, height, width, 2*height))# 把边缘过滤FIND_EDGES的图像放置在右下角 edges img.filter(PIL.ImageFilter.FIND_EDGES) res.paste(edges, (width, height, 2*width, 2*height))# 显示结果图像 res.show()4.批量图像格式转换 save 使用PIL.Image模块的open()函数打开磁盘图像文件时会根据文件内容自动确定文件格式。使用Image对象的save()方法保存图像时可以指定格式从而实现格式转换。 glob模块可以使用通配符匹配文件名。例如glob.glob(c:\tmp\*.jpg)可以返回指定目录下所有后缀为jpg的文件列表。 os.path.splitext()可以拆分文件名和后缀。 import sys import glob import os import PIL.Imageimg_path sys.argv[1] /*. sys.argv[2] for infile in glob.glob(img_path):f, e os.path.splitext(infile)outfile f . sys.argv[3]PIL.Image.open(infile).convert(RGB).save(outfile, sys.argv[3]) # python main.py . png jpeg先转换为RGB然后由RGB转换为指定的格式 注意jpg后缀的文件格式全名为JPEG。 5.批量创建缩略图 thumbnail 缩略图是网络开发或图像软件预览常用的一种基本技术使用Image对象的thumbnail()方法可以很方便地建立缩略图。 import sys import glob import os import PIL.Imageimg_path sys.argv[1] /*. sys.argv[2] size(128,128) for infile in glob.glob(img_path):f, e os.path.splitext(infile)outfile f _s. sys.argv[2]img PIL.Image.open(infile)img.thumbnail(size)img.save(outfile) # python main.py . jpgthumbnail()函数是Pillow库中的一个方法用于调整图像的大小。该函数可以根据指定的尺寸或比例自动调整图像的大小同时保持图像的宽高比。 thumbnail(size, resampleNone)size一个元组或整数指定缩略图的目标尺寸。如果size是一个整数则图像将按照宽度和高度的相同比例进行缩放。如果size是一个元组可以指定宽度和高度的具体值或者使用其中一个维度值为None来自动计算缩放比例。resample可选指定缩放算法。默认为None表示使用默认的缩放算法。常用的选项包括Image.NEAREST最近邻插值、Image.BILINEAR双线性插值和Image.BICUBIC双三次插值。如果需要更高质量的缩放结果可以选择Image.LANCZOSLanczos插值6.批量图像加文字、图片水印 blend composite 使用Image模块的new函数可以创建水印图像对象使用ImageDraw模块在水印图像上绘制文字最后通过Image模块的composite函数合成水印图像和原图像。 # 把指定路径下所有*.jpg文件加上Python水印并另存为*_w.jpg # python main.py . jpg Python import sys import glob import os from PIL import Image, ImageDraw, ImageFontimg_path sys.argv[1] /*. sys.argv[2] img_suffix sys.argv[2] text sys.argv[3] # 水印字体文件 fnt ImageFont.truetype(arial.ttf, 36)for infile in glob.glob(img_path):f, e os.path.splitext(infile)outfile f _w. sys.argv[2]img Image.open(infile)# 创建水印图层wartermark Image.new(img.mode, img.size)print(wartermark.size, wartermark.format,wartermark.mode)# 创建绘图对象 在水印图层上绘制水印文字draw ImageDraw.Draw(wartermark)draw.text((50,60), text, fontfnt)# 将水印图层混合到原始图像上img_out Image.blend(img, wartermark, 0.5)# img.save(outfile, JPEG)img_out.show()alpha_composite还有composite不成功。是因为要有alpha通道。下面加图片水印使用png格式。 # python main.py . png Python # 替换下面代码 r, g, b, alpha img.split() alpha alpha.point(lambda i: i 0 and 204)# 将水印图层混合到原始图像上 img_out Image.composite(img, wartermark, alpha)7.批量调整图像大小resize resize()函数是Pillow库中的一个方法用于调整图像的尺寸。该函数可以根据指定的尺寸进行缩放或裁剪图像。 resize(size, resampleNone, boxNone)from PIL import Image# 打开图像 image Image.open(image.jpg)# 按照比例缩小图像 scale_factor 0.5 new_width int(image.width * scale_factor) new_height int(image.height * scale_factor) resized_image image.resize((new_width, new_height))# 保存调整后的图像 resized_image.save(resized_image.jpg)# python main.py . png 200 200 将当前目录下所有png格式调整到200x200 import sys import glob import os from PIL import Imageimg_path sys.argv[1] /*. sys.argv[2] text sys.argv[3] img_size_width int(sys.argv[3]) img_size_height int(sys.argv[4])for infile in glob.glob(img_path):f, e os.path.splitext(infile)outfile f _w. sys.argv[2]img Image.open(infile)img_out img.resize((img_size_width, img_size_height))# img.save(outfile, JPEG)img_out.show()
http://www.zqtcl.cn/news/213979/

相关文章:

  • 怎么把网站放到服务器上站长工具seo综合查询外部链接数量
  • 做网站上市的公司开一家公司最低注册资金
  • 仙居谁认识做网站的有哪些好的网站建设
  • 互动广告机网站建设怀集网站建设
  • 好的 做网站的软件公司pinterest app下载
  • 公司网站报价邯郸软件定制
  • 产品毕业设计代做网站资料库网站源码
  • 交易类网站做支付宝功能建设银行网站收款怎么打明细
  • 广州找人做网站做网站网关备案
  • 网站的布局方式有哪些内容免费ppt模板下载公众号
  • 色91Av做爰网站获胜者网站建设
  • 企业做网站要多少钱简单网页设计模板网站
  • 住宅城乡建设部门户网站seo主管的seo优化方案
  • 商洛做网站电话北京做网站比较大的公司
  • 某俄文网站电脑做网站服务器
  • 广州网站建设开发团队江苏省建设招标网站
  • 南昌建设工程质量监督网站wordpress菜单登录
  • 网站设计贵不贵网站seo设置是什么
  • 不属于企业网站建设基本标准的是南通网站建设知识
  • 玉树州wap网站建设公司做试玩网站
  • 商城网站怎么建保定网络营销网站建设
  • 检索类的网站建设公司的网站建设规划书
  • 百度做网站需要交钱吗保定网站建设平台分析
  • 张家界建设局网站电话优化关键词排名公司
  • 宁夏网站建设一条龙网站建设中的图片及视频要求
  • 某些网站dns解析失败湛江制作企业网站
  • 网站开发用什么代码长沙哪家公司做网站
  • 做视频找素材的网站有哪些wordpress 合法评论
  • php网站开发程序填空题高水平网站运营托管
  • 揭东建设局网站wordpress建站后发布