» » Image upload and clipping applications: Croppie

 

Image upload and clipping applications: Croppie

Author: bamboo06 on 1-08-2016, 01:40, views: 4930

19
In a lot of applications need to upload the local images and then by size appropriate tailoring to meet the requirements of the website for the size of the picture. The most common is the user system requires users to upload and cut the picture of the application. Today I introduced to you is based on HTML5 and jQuery of the picture upload and clipping plug-in, it is called Croppie.


HTML
First, we will load the relevant JS and CSS files in head.
<script src="jquery.min.js"></script> 
<script src="croppie.min.js"></script> 
<link rel="stylesheet" href="croppie.css"> 

Next we put a picture upload button on the page, we can use type= to CSS "file" file select control into button style. After selecting the picture, in the #upload-demo display upload pictures, as well as call clipping Croppie. #result is used to display the cut after the picture.
<div class="actions"> 
    <button class="file-btn"> 
        <span>Upload</span> 
        <input type="file" id="upload" value="Select" /> 
    </button> 
    <div class="crop"> 
        <div id="upload-demo"></div> 
        <button class="upload-result">Croppie</button> 
    </div> 
    <div id="result"></div> 
</div> 


CSS
Using the following CSS code, we are perfect to select the file control into the button style, in fact, the type= "file" transparency is set to 0, and then overlap and button. In addition, we first set the image cropping area.Crop is not visible, and then select the file to display.
button, 
a.btn { 
    background-color: #189094; 
    color: white; 
    padding: 10px 15px; 
    border-radius: 3px; 
    border: 1px solid rgba(255, 255, 255, 0.5); 
    font-size: 16px; 
    cursor: pointer; 
    text-decoration: none; 
    text-shadow: none; 
} 
button:focus { 
    outline: 0; 
} 
 
.file-btn { 
    position: relative; 
} 
.file-btn input[type="file"] { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    opacity: 0; 
} 
 
.actions { 
    padding: 5px 0; 
} 
.actions button { 
    margin-right: 5px; 
} 
.crop{display:none} 


JQuery
First use FileReader API HTML5 to read the local file, and then $('#upload-demo').Croppie () called the Croppie plug-in. Croppie option viewport: you can set the width and height of the cropped image, as well as type (round or square); option boundary is the peripheral size of the picture. It also has parameters mouseWheelZoom: whether to support the mouse wheel zoom image; showZoom: whether to display the zoom bar tool; update: callback function.
$(function(){ 
    var $uploadCrop; 
 
        function readFile(input) { 
             if (input.files && input.files[0]) { 
                var reader = new FileReader(); 
                 
                reader.onload = function (e) { 
                    $uploadCrop.croppie('bind', { 
                        url: e.target.result 
                    }); 
                } 
                 
                reader.readAsDataURL(input.files[0]); 
            } 
            else { 
                alert("Sorry - you're browser doesn't support the FileReader API"); 
            } 
        } 
 
        $uploadCrop = $('#upload-demo').croppie({ 
            viewport: { 
                width: 200, 
                height: 200, 
                type: 'circle' 
            }, 
            boundary: { 
                width: 300, 
                height: 300 
            } 
        }); 
 
        $('#upload').on('change', function () {  
            $(".crop").show(); 
            readFile(this);  
        }); 
        $('.upload-result').on('click', function (ev) { 
            $uploadCrop.croppie('result', 'canvas').then(function (resp) { 
                popupResult({ 
                    src: resp 
                }); 
            }); 
        }); 
         
    function popupResult(result) { 
        var html; 
        if (result.html) { 
            html = result.html; 
        } 
        if (result.src) { 
            html = '<img src="' + result.src + '" />'; 
        } 
        $("#result").html(html); 
    } 
}); 

When you click the "cut" button, call the result Croppie method again, after returning to a clip of the picture, and displayed in the #result.

Category: Javascript / HTML5 / Plugins

Dear visitor, you are browsing our website as Guest.
We strongly recommend you to register and login to view hidden contents.
<
  • 0 Comments
  • 0 Articles
27 April 2017 05:43

Gallton

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Hmm nice of you ot have let us know about it all, surely helped with custom college papers. You have done an amazing job with it all, keep up the good work! Please keep on sharing about such softwares in the future too!

<
  • 0 Comments
  • 0 Articles
18 July 2017 21:41

Daniel J. McGlothlin

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
As being a college student, I used to get many essays on every weekend to be done. And frankly, I was just fed up of writing essays than one of my brother suggested me to try essay writing lab UK.

<
  • 0 Comments
  • 0 Articles
22 July 2017 01:35

ewfdwe

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
One of biggest misconceptions about Rolex is that machines build their cheap rolex watches. The rumor is so pervasive that even people at a Blogto Watch believed it to be mostly true. This is because traditionally Rolex didn't communicate much on this topic. Well the truth is that rolex replica watches are given all the hands-on human attention that you'd like to expect from a fine Swiss made watch.

<
  • 0 Comments
  • 0 Articles
31 July 2017 23:27

Donna W. Daniels

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Am glad to see my new home. But there's Roof was so rough and old fashion, so I want to change it. Am, so concern about the roofing company but my family member suggest me to <a href="oakleysroofing.com">Oakleys Roofing</a>. So I consult with them, and they are expert roof consulting services.

<
  • 0 Comments
  • 0 Articles
31 August 2017 12:36

ali

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
It is somewhat fantastic, and yet check out the advice at this treat. Benefits of Coconut Water

<
  • 0 Comments
  • 0 Articles
2 September 2017 21:01

Rokki

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
wow!Thank this meaningful and helpful post !And I like help people make research paper admission essay editing service

<
  • 0 Comments
  • 0 Articles
3 September 2017 22:55

ali

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Cool you inscribe, the info is really salubrious further fascinating, I'll give you a connect to my scene. Text Your Ex Back

There you can download for free, see the first of these data. The Magic of Making Up

<
  • 0 Comments
  • 0 Articles
8 September 2017 06:11

Condolence Messages

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
You completed certain reliable points there. I did a search on the subject and found nearly all persons will agree with your blog. Condolence Messages

Just pure brilliance from you here. I have never expected something less than this from you and you have not disappointed me at all. I suppose you will keep the quality work going on. Sexting Examples

<
  • 0 Comments
  • 0 Articles
10 October 2017 05:19

Conversation Starters

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
If your looking for Online Illinois license plate sticker renewals then you have need to come to the right place.We offer the fastest Illinois license plate sticker renewals in the state. Conversation Starters

<
  • 0 Comments
  • 0 Articles
25 October 2017 21:12

sandie

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
fasdfasfsf

<
  • 0 Comments
  • 0 Articles
26 October 2017 17:28

Lahoma Laipple

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
test test test test test test test

<a href="http://www.undangancinta.com">undangan pernikahan</a>
undangan pernikahan unik
https://goo.gl/XZ6zpY undangan nikah
<a href="http://bit.ly/2fZoVjU">jual hp asus murah</a>
http://www.undangancinta.com # Undangan Pernikahan
http://www.undangancinta.com # Undangan Pernikahan



碸 ĀŮ

<
  • 0 Comments
  • 0 Articles
29 October 2017 22:02

Aleksa

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
<a href="http://blog.dnevnik.hr/girlchat">more info</a>
<a href="http://www.bricksite.com/lookupadate">web page</a>
<a href="http://inmethod.com/forum/user/edit/64272.page">snapchat chatting</a>
<a href="http://nixstaller.sourceforge.net/forum/viewthread.php?thread_id=2386
">kik sexting site</a>

kik chatting
snapchat chatting
follow the link
sexting website

<
  • 0 Comments
  • 0 Articles
8 November 2017 18:14

RPSC Blog

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
The RPSC Blog board has started inviting applicants for the teacher vacancies. These are the posts that are available as of now

<
  • 0 Comments
  • 0 Articles
11 December 2017 14:39

Purushotam

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
<a href="http://www.transmoving.in/packers-movers-bangalore.html">Pack
ers and movers in bangalore</a>
<a href="http://www.transmoving.in/packers-movers-gurgaon.html">Packer
s and movers in gurgaon</a>
<a href="http://www.transmoving.in/packers-movers-delhi.html">Packers and movers in delhi</a>
<a href="http://www.transmoving.in/packers-movers-mumbai.html">Packers
and movers in mumbai</a>
<a href="http://www.transmoving.in/packers-movers-hyderabad.html">Pack
ers and movers in hyderabad</a>
<a href="http://www.transmoving.in/packers-movers-pune.html">Packers and movers in pune</a>
<a href="http://www.transmoving.in/packers-movers-chandigarh.html">Pac
kers and movers in chandigarh</a>
<a href="http://www.transmoving.in/packers-movers-kolkata.html">Packer
s and movers in kolkata</a>
<a href="http://www.transmoving.in/packers-movers-chennai.html">Packer
s and movers in chennai</a>
<a href="http://www.transmoving.in/packers-movers-patna.html">Packers and movers in patna</a>
<a href="http://www.transmoving.in/packers-movers-noida.html">Packers and movers in noida</a>
<a href="http://www.transmoving.in/packers-movers-dwarka%20delhi.html">
;Packers and movers in dwarka delhi</a>
<a href="http://www.transmoving.in/packers-movers-faridabad.html">Pack
ers and movers in faridabad</a>
<a href="http://www.transmoving.in/packers-movers-goa.html">Packers and movers in goa</a>
<a href="http://www.transmoving.in/packers-movers-indore.html">Packers
and movers in indore</a>
<a href="http://www.transmoving.in/packers-movers-jaipur.html">Packers

<
  • 0 Comments
  • 0 Articles
24 January 2018 01:43

LarryJok

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Hi everyone my nme is ed marketing sales.I,m here to offer some internet services.Nice to be here
https://best-rehab-center.us.com

<
  • 0 Comments
  • 0 Articles
17 February 2018 22:07

FilmoraGo APK

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
Information
Comment on the news site is possible only within (days) days from the date of publication.