• 移动端实现裁剪图片生成base64图片(可缩放)


    移动端实现裁剪图片生成base64图片(可缩放)
    <pre>
    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="utf-8" />
    <title>{$title}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no" />
    <meta name="format-detection" content="telephone=no" />
    <!-- Link Swiper's CSS -->
    <include file="commonheader" />
    <link href="/croppermaster/dist/cropper.css" rel="stylesheet">
    <style type="text/css">

    </style>
    </head>

    <body>
    <div class="box" style="100%;height:100%; position: absolute;left:0px; top:0px; z-index: 9999;background: #000;">
    <img class="image" src="/croppermaster/dist/1.jpg">
    <div class="caijian" style="80px; height:30px; line-height: 30px; text-align: center; background: #0ac2ff; border-radius:10px; position: absolute;right:30px; bottom: 30px; color: #FFF;">确定</div>
    <div class="quxiaocaijian" style="80px; height:30px; line-height: 30px; text-align: center; background: #0ac2ff; border-radius:10px; position: absolute;left:30px; bottom: 30px; color: #FFF;">取消</div>
    <div style="100%; height: auto;overflow: hidden;">
    <img style="30%;" class="showpic" src="" alt="">
    </div>
    </div>

    <include file="commonfooter" />
    <script src="/croppermaster/dist/cropper.js"></script>
    <script type="text/javascript">
    $(function() {
    $('.image').cropper({
    aspectRatio: 9 / 12,
    viewMode: 1,
    crop: function(e) {
    // console.log(e);
    }
    });

    //裁剪完压缩方法
    $('.caijian').on('click', function() {
    var result = $('.caijianpic').cropper("getCroppedCanvas", {
    750,
    height: 1000
    });

    var base64img = result.toDataURL("image/jpg");
    $('.showpic').attr('src', base64img);
    })
    $('.quxiaocaijian').on('click', function() {
    $('.image').cropper("destroy")
    })

    })
    </script>
    </body>

    </html>
    </pre>

    ps:这个案例是裁剪中状态的

  • 相关阅读:
    自己感受,如何解读别人的好的PHP代码
    34. RunAs Authentication Replacement运行身份验证替换
    32.3.3 Authenticating to a Stateless Service with CAS(使用CAS向无状态服务进行身份验证)
    33.2 Adding X.509 Authentication to Your Web Application
    35.2 Encryptors加密器
    32.3.2 Single Logout(单点退出)
    33. X.509 Authentication
    34.2 Configuration
    32.3.4 Proxy Ticket Authentication代理票证认证
    35.3 Key Generators密钥生成器
  • 原文地址:https://www.cnblogs.com/newmiracle/p/11871357.html
Copyright © 2020-2023  润新知