


javascript screenshot jQuery plug-in imgAreaSelect usage detailed explanation_jquery
In order to enable users to customize personal avatars, it is necessary to provide a screenshot function of uploaded pictures. Currently, many websites, especially SNS websites, provide such a function, which is very practical. There are two main forms of implementation, one is flash screenshots, and the other is javascript screenshots. Both methods have their own pros and cons. Regarding Flash screenshots, you can refer to the avatar upload function in the UcHome program, but this is not the topic I want to discuss. My main focus here is how to implement javascript screenshots, using jQuery's imgAreaSelect plug-in to easily implement the custom avatar [avatar] javascript screenshot function.
1. Preparation:
Two JS files
1. jquery.js download: jquery.js
2. jquery.imgareaselect.js Download: jquery.imgareaselect.js[imgareaselect-0.6.2.zip]
2. Use
function preview(img, selection){ var scaleX = 100 / selection.width; var scaleY = 100 / selection.height;
//Dynamic avatar Get the width, height, left border, and right border of the currently selected box
$('#biuuu + div > img').css({ width: Math.round(scaleX * 400) + 'px', height: Math.round(scaleY * 300) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); }
//Load small avatar
$(document).ready(function () { $('<div><img src="biuuu.jpg" style="position: relative;" /></div>') .css({ float: 'left', position: 'relative', overflow: 'hidden', width: '100px', height: '100px' }) .insertAfter($('#biuuu')); });
//Initial loading
$(window).load(function () { $('#biuuu').imgAreaSelect({ aspectRatio: '1:1', onSelectChange: preview }); });
Three, call
<div class="container"> <p> <img id="biuuu" src="biuuu.jpg" title="biuuu" style="float: left; margin-right: 10px;" /> </p> </div>
Using the above javascript screenshot to expand can achieve many dynamic functions. The imgAreaSelect plug-in provided by jQuery is very simple to call. For other related applications, please refer to: imgAreaSelect Examples
It is very simple to use the jQuery plug-in imgAreaSelect to implement javascript screenshots. It is basically a dynamic image display, obtaining the position of the source image and the size of the selection box [width and height], and easily realizing the javascript screenshot function.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

1. Press the win key + r key, enter regedit, and click OK. 2. In the opened registry editor window, expand: HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlGraphicsDriversDCI, select Timeout on the right and double-click. 3. Then change 7 in [Numeric Data] to 0, and confirm to exit.

Recently, many consumers are considering replacing their mobile phones, and Redmi13C is a very cost-effective choice. The performance configuration of this phone is excellent. In order to facilitate daily use, let me briefly introduce how to take screenshots on Redmi 13C. Let’s find out together! How to take a screenshot on Redmi 13c 1. Shortcut key to take a screenshot: Press the power button and volume down key of the Redmi phone at the same time to take a screenshot. 2. Gesture screenshot: Enter the settings of the Redmi phone, find "More settings", find and click "Gesture and key shortcuts", then enable the "three-finger pull-down" operation and set it to take a screenshot. In this way, when you need to take a screenshot, you only need to slide down on the screen with three fingers to take a screenshot. 3. Take a screenshot of the notification bar: from the phone screen

Screenshot feature not working on your iPhone? Taking a screenshot is very easy as you just need to hold down the Volume Up button and the Power button at the same time to grab your phone screen. However, there are other ways to capture frames on the device. Fix 1 – Using Assistive Touch Take a screenshot using the Assistive Touch feature. Step 1 – Go to your phone settings. Step 2 – Next, tap to open Accessibility settings. Step 3 – Open Touch settings. Step 4 – Next, open the Assistive Touch settings. Step 5 – Turn on Assistive Touch on your phone. Step 6 – Open “Customize Top Menu” to access it. Step 7 – Now you just need to link any of these functions to your screen capture. So click on the first

How to use shortcut keys to take screenshots in Win8? In our daily use of computers, we often need to take screenshots of the content on the screen. For users of Windows 8 system, taking screenshots through shortcut keys is a convenient and efficient operation method. In this article, we will introduce several commonly used shortcut keys to take screenshots in Windows 8 system to help you take screenshots more quickly. The first method is to use the "Win key + PrintScreen key" key combination to perform full

Screenshot is a tool used to capture important data or information on your phone or computer screen. Capable of recording exactly what you see in an instant, it's a convenient way to record, share or save visual information. The Ubuntu operating system provides a variety of screenshot methods. Users can choose to capture the entire desktop, a specific window, or a customized area. These features allow Ubuntu users to easily capture key information on the screen, improving work efficiency and the convenience of sharing information. In this article, we'll look at how to take screenshots using the desktop app and keyboard shortcuts. Method 1: Use Shortcut Keys to Take Screenshots Manual snapshots are usually the default and commonly used method because they are relatively easy to get started. For the average user, no complex photos or videos are required

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

What are the shortcut keys for taking screenshots in Win8? The Windows 8 operating system provides a variety of shortcut keys for the screenshot function, allowing users to take screenshots conveniently and quickly. The following are some commonly used Win8 screenshot shortcut keys: Win+PrtScn: Press the Windows key (Win) and press the PrtScn key at the same time to quickly take a full-screen screenshot and automatically save it to the "Screenshot" subfolder in the "Photos" folder . Alt+PrtScn: Press the Alt key

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <
