


ionic local photo album, photo taking, cropping, uploading skills sharing
The existing ionic picture selection upload blogs on the Internet are too fragmented, have incomplete functions, or introduce some unnecessary plug-ins. This time, we took the project as an opportunity to integrate ionic's image selection, cropping, and uploading. To upload multiple images, please click ionic to select multiple images to upload. This article mainly introduces the ionic local photo album, taking pictures, cropping, and uploading (full version of a single picture). It is very practical. Friends who need it can refer to it. I hope it can help everyone.
Plug-in installation
cordova plugin add cordova-plugin-camera //用于通过相机、相册选择图片并完成裁剪 cordova plugin add cordova-plugin-file-transfer //用于上传图片到服务器
Encapsulate functions as services
angular.module('starter.services', []) //文件上传 .factory('UploadFile', function(Toast) { return { /** * 上传文件到服务器 * * @param fileUrl 文件路径 * @param server 服务器接口 */ uploadFile: function(fileUrl, server) { document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { var options = new FileUploadOptions(); options.fileKey = "BeanYon"; options.fileName = fileUrl.substr(fileUrl.lastIndexOf('/') + 1); options.mimeType = "image/jpeg"; options.chunkedMode = false; var params = {account: localStorage.account}; options.params = params; var ft = new FileTransfer(); ft.upload(fileUrl, encodeURI(server), success, err, options); } function success(r){ Toast.show("设置头像成功"); } function err(error){ Toast.show("上传头像失败,请确保网络正常后再试"); } } } }) //配置单张图片选择 .factory('SelectPicture', function(UploadFile, Toast) { return { /** * 从相机或图库选择一张图片 * * @param type 选择类型,0 拍照,1 相册 * @param width 目标宽度 * @param height 目标高度 * @param scope $scope对象 */ chooseSinglePicture: function(type, width, height, scope) { document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { var options = {//相机配置 targetWidth: width, targetHeight: height, quality: 100, allowEdit: true } if(type == 1){//图片源设置为相册 options.sourceType = 2; } navigator.camera.getPicture( function(res){ scope.avatar_src = res; scope.$apply(); localStorage.avatar = res; UploadFile.uploadFile(res, "我的服务器地址");//传递自己的服务器接口地址 }, function(res){ Toast.show("选择头像失败"); }, options ); } }, /** * 从图库选择多张图片 */ choosePictures: function() { window.imagePicker.getPictures(function(res){ alert(res+",success"); }, function(res){ alert(res+",failed"); }, { maximumImagesCount: 10, width: 80, height: 80, quality: 80 }); } } });
Call service
##
angular.module('starter.controllers', []) .controller('MyCtrl', function($scope, $state, $ionicActionSheet, UploadFile,Toast, SelectPicture) { $scope.avatar_src = "img/default_avatar.jpg"; /** *选择头像 */ $scope.selectAvatar = function(){ // 显示操作表 $ionicActionSheet.show({ buttons: [ { text: '<p style="font-size: 18px;">拍照<p>' }, { text: '<p style="font-size: 18px;">从相册选择<p>' }, ], buttonClicked: function(index) { //设置头像 SelectPicture.chooseSinglePicture(index, 120, 120, $scope); return true; } }); } })
Ionic multi-image upload sample code sharing
ionic3 and Angular4 implement interface request and local json file reading
Use ionic implements address book interface switching example code
The above is the detailed content of ionic local photo album, photo taking, cropping, uploading skills sharing. For more information, please follow other related articles on the PHP Chinese website!

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



Inline frames are called iframes in HTML. A label specifies a rectangular area within the content where the browser can display different documents with scroll bars and borders. To embed another document within the current HTML document, use inline frames. A reference to an element can be specified using the HTMLiframe name attribute. In JavaScript, references to elements are also made using the name attribute. An iframe is essentially used to display a web page within the currently displayed web page. The URL of the document containing the iframe is specified using the "src" attribute. Syntax The following is the syntax of HTML <iframesrc="URL"title="d

In order to make the photos taken more personalized and unique, Xiaomi Mi 14 provides photo watermark settings. By setting photo watermarks, users can add patterns, text and logos to the photos they take, so that each photo can better record precious moments and memories. Next, we will introduce how to set a photo watermark in Xiaomi 14 to make your photos more personalized and vivid. How to set photo watermark on Xiaomi Mi 14? 1. First click “Camera”. 2. Then click "Settings". 3. Then find the watermark, and then you can start shooting.

News on February 9th, with the sound of firecrackers and the blooming of fireworks, I wish everyone a happy New Year's Eve. It's time to set off fireworks again, and many people will take out their mobile phones to take a few photos and share them on their WeChat Moments. If you are using a domestic smartphone, the photos will basically be optimized by AI to make the fireworks more effective. How do users holding iPhones take photos of fireworks? Tonight, the entry #iPhone Shooting Fireworks Mode# was on the hot search list on Weibo, attracting many netizens to watch. In fact, the so-called iPhone "Fireworks Mode" is to take photos simultaneously in video mode. First, open the camera that comes with the iPhone, switch to "Video" mode, click on the parameters in the upper right corner, and adjust the resolution to 4K and the frame rate to 60fp
![Why is the iPhone 13's photos unclear? [Solution to the latest iPhone blurry photos]](https://img.php.cn/upload/article/000/000/164/170723079771931.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
Set the focus for your subject Improper focus is one of the common causes of blurry photos, and is also affected by light. Most people usually shoot with autofocus, and the results are usually pretty good. However, the autofocus can sometimes disappoint, resulting in images similar to the photo above. For best results, you can touch the screen in the iPhone's built-in camera app to set the focus manually. Sufficient light Sufficient light will not only allow you to get clearer photos, but also improve the quality of the photos. Whether you are shooting landscapes or portraits, you should ensure that there is sufficient light under the iPhone lens. When the shutter is open for a longer time, the movement may be slower. Too much will lead to blur. Generally, the scene should be carried out in a place with sufficient indoor light or a place with sufficient natural light outdoors.

1. How to remove the watermark from cute photos? Tutorial on how to turn off the watermark on faceu’s cute photos! 1. Open the Faceu app on your phone and click on the shooting icon. 2. After entering the shooting interface, select the three-dot icon. 3. Then in the pop-up panel, click Camera Settings. 4. After jumping to the page, select watermark settings. 5. Finally, on the watermark setting page, click to turn off the watermark.

Some users find that some things in the picture are crooked and cannot be directly selected and cropped. Is there any way to straighten the things in the picture? In fact, this operation is very simple for PS masters. Here, the editor will tell the novice PS users how to crop crooked pictures into straight ones in Photoshop. This method is very easy to operate. I hope it can help everyone. PS tutorial for cropping tilted photos 1. Open Photoshop, move the mouse to the cropping tool on the left, then right-click the mouse and select "Perspective Cropping Tool". 2. Select the picture that needs to be straightened and determine the four points. 3. Then press the Enter key to straighten it successfully. 4. In this way, the things in the photo will be corrected, and

With the iOS 17 Photos app, Apple makes it easier to crop photos to your specifications. Read on to learn how. Previously in iOS 16, cropping an image in the Photos app involved several steps: Tap the editing interface, select the crop tool, and then adjust the crop using a pinch-to-zoom gesture or dragging the corners of the crop tool. In iOS 17, Apple has thankfully simplified this process so that when you zoom in on any selected photo in your Photos library, a new Crop button automatically appears in the upper right corner of the screen. Clicking on it will bring up the full cropping interface with the zoom level of your choice, so you can crop to the part of the image you like, rotate the image, invert the image, or apply screen ratio, or use markers

According to news on February 22, the imaging hardware of Xiaomi Mi 14 Ultra has been upgraded again this time. The main camera is equipped with Sony’s second-generation 1-inch main camera LYT-900, which has performance far exceeding IMX989. The sensor is 50 million pixels, has a 1/0.98-inch ultra-large base, and a single pixel size of 1.6μm. It is equipped with Xiaomi’s second-generation stepless variable aperture technology, and the maximum aperture can reach ƒ/1.63. Compared with IMX989, LYT-900's power consumption is reduced by 43%, and it reaches 14EV native super dynamic range, which is 9.5 times that of IMX989, and can retain rich light and dark details. Thanks to this, the comprehensive light intake of Xiaomi Mi 14 Ultra is 205% of that of iPhone 15 Pro Max, which is a
