社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Warren Weckesser

Warren Weckesser 最近创建的主题
Warren Weckesser 最近回复了
2 年前
回复了 Warren Weckesser 创建的主题 » 如何在Python中对数据(scipy.optimize)使用Breit-Wigner/Lorentzian

你有理由 np.trapz 颠倒的。应该是的

normalization_factor = np.trapz(y_vals, x_vals)
5 年前
回复了 Warren Weckesser 创建的主题 » 在Python中将png文件转换为动画gif

老问题,很多好的答案,但可能还有兴趣在另一个选择。。。

这个 numpngw https://github.com/WarrenWeckesser/numpngw )可以从numpy数组中编写动画PNG文件。( 更新 新浪 现在在pypi上: https://pypi.python.org/pypi/numpngw

例如,此脚本:

import numpy as np
import numpngw


img0 = np.zeros((64, 64, 3), dtype=np.uint8)
img0[:32, :32, :] = 255
img1 = np.zeros((64, 64, 3), dtype=np.uint8)
img1[32:, :32, 0] = 255
img2 = np.zeros((64, 64, 3), dtype=np.uint8)
img2[32:, 32:, 1] = 255
img3 = np.zeros((64, 64, 3), dtype=np.uint8)
img3[:32, 32:, 2] = 255
seq = [img0, img1, img2, img3]
for img in seq:
    img[16:-16, 16:-16] = 127
    img[0, :] = 127
    img[-1, :] = 127
    img[:, 0] = 127
    img[:, -1] = 127

numpngw.write_apng('foo.png', seq, delay=250, use_palette=True)

创建:

animated png

您需要一个支持动画PNG的浏览器(直接或通过插件)来查看动画。

5 年前
回复了 Warren Weckesser 创建的主题 » python如何将dst文件转换成png文件?

将png文件写入 'shamrockin.dst' ,它将覆盖原始文件。当你第二次运行时, 'shamrocking.dst' 现在是PNG文件,因此无法读取 read_dst . (错误信息中有一条线索 UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte :字节0x89总是 first byte of a PNG file )

还原原始DST文件,并更改

pyembroidery.write_png(pattern, 'shamrockin.dst')

pyembroidery.write_png(pattern, 'shamrockin.png')