PIL for construct a Image file from STRING or BUFFER
2009-09-15 16:46
633 查看
Can invoke Image.fromstring() to construct a Image file, but need NOTE that:
Image.fromstring() only decodes pixel data, not entire imgages. If the string contain an entire image file, wrap it in a StringIO object, and use Image.open() to load it.
For Example:
Image.fromstring() only decodes pixel data, not entire imgages. If the string contain an entire image file, wrap it in a StringIO object, and use Image.open() to load it.
For Example:
]import urllib import StringIO from PIL import Image content = urllib.urlopen("http://www.xxxx.com/aimage.bmp") data = content.read() strBuf = StringIO.StringIO(data) #img = Image.fromstring("RGB", (39,11), data) #img = img.transpose(Image.FLIP_TOP_BOTTOM) img = Image.open(strBuf, 'r') img.save("from_url.bmp", "BMP")
相关文章推荐
- Image.FromFile gives "Out of Memory" Exception for icon
- 解决错误:NAND: could not create temp file for system NAND disk image: No such file or directory
- Windows Mobile中实现Image.FromFile(string file)这样的方法
- How to resize or create a thumbnail image from file stream on UWP
- from Export image to TIF or TIFF file of selected
- BufferHelp byte[] Stream string FileStream Image Bitmap
- C# 中使用Image.FromFile(string path)后,提示该文件正在被另一进程使用XXX的问题
- C# 中使用Image.FromFile(string path)后,提示该文件正在被另一进程使用XXX的问题
- 解决错误:NAND: could not create temp file for system NAND disk image: No such file or directory
- ReactJs 报错 Element type is invalid: expected a string (from built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `Me`.
- PHP Download Image Or File From URL
- Windows Mobile中实现Image.FromFile(string file)这样的方法
- 编译C++,找不到头文件(fatal error: string: No such file or directory)
- How to remove space or newline characters from a string?
- SharePoint 2007 Prompt for Credentials When Accessing FQDN Sites From a Windows Vista or Windows 7 Computer
- Csharp: Create Excel Workbook or word from Template File using aspose.Word 14.5 and aspose.Cell 8.1
- [iOS] How to disable/enable arc for single or mutil file
- Unhandled Exception: System.BadImageFormatException: Could not load file or assembly (2008R2配置x64website)
- Ambari安装hive组件出现need string or buffer, NoneType found
- 606. Construct String from Binary Tree