• 移动端实现裁剪图片生成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:这个案例是裁剪中状态的

  • 相关阅读:
    elasticsearch painless脚本评分
    elasticsearch relevance score相关性评分的计算
    java 多线程间通信(二)
    java 多线程间通信(一)
    java CountDownLatch、CyclicBarrier和 Semaphore用法
    java 深入剖析ThreadLocal
    java中String、StringBuffer、StringBuilder的区别
    Leetcode: LRU Cache
    Leetcode: Anagrams(颠倒字母而成的字)
    Leetcode: First Missing Positive
  • 原文地址:https://www.cnblogs.com/newmiracle/p/11871355.html
Copyright © 2020-2023  润新知