Chinaunix首页 | 论坛 | 博客
  • 博客访问: 267660
  • 博文数量: 82
  • 博客积分: 2477
  • 博客等级: 大尉
  • 技术积分: 725
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-06 23:24
文章分类

全部博文(82)

文章存档

2013年(1)

2012年(3)

2011年(15)

2010年(36)

2009年(27)

分类: 系统运维

2011-05-31 13:28:27

    前一段时间,在做项目时,遇到了要进行图片格式转换的问题,而且是将png/jpg或其他常见格式的图片转换为svg图片,后来经过网上调查,以及对比jpg,png图片源码,发现了如下的转换方法,现在贴出来,希望对有需要的同学能有帮助,同时也做个备份,哈哈。
【php code】
$svg_head="                                                                                                             
                                                                                                                 
                                                                                                                                                        
                           ]>                                                                                                                                                     
                                                          xmlns=\"" xmlns:xlink=\"" xmlns:a=\""   
                                x=\"0px\" y=\"0px\" width=\"44px\" height=\"44px\" viewBox=\"0 0 44 44\" enable-background=\"new 0 0 44 44\" xml:space=\"preserve\">              
                                                                                                                                                                            
                       
                                                                                                                                                   
                                        $svg_footer = "\">                                                                                                                                                
                                                                                                                                                                          
                        ";                                                                                                                                                  
                $tmpfile = file_get_contents($tmpjpg);                                                                                                                            
                $content = base64_encode($tmpfile);                                                                                                                               
                $svgfile = $svg_head."\n".$content."\n$svg_footer";  
    最后,将$svgfile写入到以svg扩展名的文件中,这样,SVG图片就可以生成了。
阅读(3347) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~