Image to CSS
来源:互联网 发布:java找不到对象 编辑:程序博客网 时间:2024/06/06 04:11
Image to CSS
Warning: 我警告过了,浏览器弱爆了的就不要点开了= =。内存太小了就慎重打开= =
眼残,竟然看到这种奇葩的演示
看了看CSS源码,想起来可以用Python Image Library做一个generator。
结果就真得做了一个……
Codes
#! /bin/env python# -*- coding: utf-8 -*-"""Script to turn image into css"""import Imageimport sys__author__ = "Reverland (lhtlyy@gmail.com)"def getcss(im): """docstring for get""" css = """position: absolute; top: 30px; left: 30px; width: 0; height: 0; box-shadow: """ string = '%dpx %dpx 0px 1px rgb%s,\n' for y in range(0, im.size[1], 1): for x in range(0, im.size[0], 1): if im.size[1] - y <= 1 and im.size[0] - x <= 1: string = '%dpx %dpx 0px 1px rgb%s;\n' color = im.getpixel((x, y)) css += string % (x, y, color) return cssdef gethtml(css): """docstring for gethtml""" html = """ <div style=" %s"></div> """ % css return htmlif __name__ == '__main__': filename = sys.argv[1] #outfile = sys.argv[2] im = Image.open(filename) ratio = 0.5 size = (int(ratio * im.size[0]), int(ratio * im.size[1])) im.thumbnail(size) html = gethtml(getcss(im)) print html # with open(outfile, 'wb') as f: # f.write(html)
Demo
点击显示图像
意义?
意义在于可能你会死机= =
尝试复制看看?
- Image to CSS
- css---Using Background-Image to Replace Text
- How to rotate an image with CSS under different browser
- iOS: load external image and css to UIWebView
- Image to Image 几何校正
- image to stream & stream to image
- CSS Image Maps
- css image light
- CSS Image Opacity / Transparency
- CSS细节--background-image
- css image 热区
- CSS background-image属性
- Image To Access
- Image To SQL Server
- Save Image to UserDefaults
- C# PDF to image
- Pdf to Image
- Image to Base64 String
- TCPDump:捕获并记录特定协议 / 端口
- C# 语言规范--1.1 开始
- 【Android基础入门〖11〗】Fragment
- win7下搭建cocos2d-x环境
- Cocos-2d 关于多个CCSprite精灵播放同一个CCAction动画问题
- Image to CSS
- JS实现图片翻书效果
- 产生死锁的四个必要条件
- 茶叶具有哪些药用功效呢?
- diff和patch
- GCC 编译配置文件 specs
- Advanced Python Constructs(译)
- 数据库之代码编写以及表格的建立
- Android中Activity的生命周期