Home > WeChat Applet > Mini Program Development > The applet uses .getImageInfo() to obtain image information

The applet uses .getImageInfo() to obtain image information

php中世界最好的语言
Release: 2018-03-23 11:00:28
Original
5590 people have browsed it

This time I will bring you the precautions on how to use .getImageInfo() in a mini program to obtain picture information, and how to use .getImageInfo() in a mini program to obtain image information. Here are Let’s take a look at practical cases.

The example in this article shares with you the specific code of Android Jiugongge picture display for your reference. The specific content is as follows

1. Knowledge points

2. Liezi

(1).When loading

<view class="zn-uploadimg">  
  <image src="{{tempFilePaths}}" mode="aspecFill" style="width: 100%; height: 450rpx" />  
  <text>图片的大小:{{imgwidth}}px*{{imgheight}}px</text> 
</view>
Copy after login
rrree

(2). When uploading pictures

var app = getApp()  
Page({ 
  data: {  
    tempFilePaths: '../uploads/foods.jpg', 
    imgwidth:0, 
    imgheight:0,  
  }, 
  onReady:function(){ 
    // 页面渲染完成  
    var _this = this;  
    wx.getImageInfo({ 
      src: _this.data.tempFilePaths, 
      success: function (res) { 
        _this.setData({ 
          imgwidth:res.width, 
          imgheight:res.height, 
        }) 
      } 
    })  
  }  
})
Copy after login
<view class="zn-uploadimg"> 
  <button type="primary"bindtap="chooseimage">获取图片</button>  
  <image src="{{tempFilePaths}}" mode="aspecFill" style="width: 100%; height: 450rpx"/>  
  <text>图片的大小:{{imgwidth}}px*{{imgheight}}px</text> 
</view>
Copy after login
.zn-uploadimg{ 
  padding:1rem; 
} 
.zn-uploadimg image{ 
  margin:1rem 0; 
}
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to develop a WeChat applet to obtain user personal information

Vue2.5 and Element UI components The paging function is implemented

The multi-file download package of the WeChat applet uses

jquery to dynamically add and traverse options

The above is the detailed content of The applet uses .getImageInfo() to obtain image information. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template