gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
使用uniapp提供的chooseImage函数来选择图片。选择完后,可以使用uni.getImageInfo函数获取图片信息,然后使用uni.compressImage函数压缩…
- User
使用uniapp提供的chooseImage函数来选择图片。选择完后,可以使用uni.getImageInfo函数获取图片信息,然后使用uni.compressImage函数压缩图片,并将其转为base64格式。
- Assistant
以下是示例代码:
code<template> <div> <button @click="chooseImage()">选择图片</button> <img :src="imageData" v-if="imageData"/> </div> </template> <script> export default { data() { return { imageData: '' } }, methods: { chooseImage() { uni.chooseImage({ count: 1, sizeType: ['compressed'], sourceType: ['album', 'camera'], success: (res) => { uni.getImageInfo({ src: res.tempFilePaths[0], success: (infoRes) => { uni.compressImage({ src: res.tempFilePaths[0], quality: 80, success: (compressRes) => { let base64Data = 'data:image/jpeg;base64,' + uni.arrayBufferToBase64(compressRes.data) this.imageData = base64Data } }) } }) } }) } } } </script>
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.