Vue-Cropper:全面掌握图片裁剪组件

Vue-Cropper 完全学习指南:Vue图片裁剪组件

🎯 什么是 Vue-Cropper?

Vue-Cropper 是一个简单易用的Vue图片裁剪组件,支持Vue2和Vue3。它提供了丰富的配置选项和回调方法,可以满足各种图片裁剪需求。

🌟 核心特点

  • 简单易用:API设计简洁,快速上手
  • 功能丰富:支持缩放、旋转、移动等操作
  • 高度可配置:提供30+个配置选项
  • 实时预览:支持实时预览裁剪效果
  • 多种输出格式:支持jpeg、png、webp格式
  • 响应式设计:适配移动端和桌面端
  • Vue2/Vue3兼容:同时支持Vue 2.x和Vue 3.x

📦 安装与引入

NPM 安装

# Vue 2.x 版本
npm install vue-cropper# Vue 3.x 版本
npm install vue-cropper@next

引入方式

全局引入
// Vue 2.x
import Vue from 'vue'
import VueCropper from 'vue-cropper' 
import 'vue-cropper/dist/index.css'Vue.use(VueCropper)// Vue 3.x
import { createApp } from 'vue'
import VueCropper from 'vue-cropper'
import 'vue-cropper/dist/index.css'const app = createApp({})
app.use(VueCropper)
局部引入
// Vue 2.x
import { VueCropper } from 'vue-cropper'
import 'vue-cropper/dist/index.css'export default {components: {VueCropper}
}// Vue 3.x
import VueCropper from 'vue-cropper'
import 'vue-cropper/dist/index.css'export default {components: {VueCropper}
}

🚀 基础使用

1. 基本示例

<template><div class="cropper-container"><!-- 图片裁剪组件 --><vue-cropperref="cropper":img="option.img":outputSize="option.outputSize":outputType="option.outputType":info="option.info":canScale="option.canScale":autoCrop="option.autoCrop":autoCropWidth="option.autoCropWidth":autoCropHeight="option.autoCropHeight":fixed="option.fixed":fixedNumber="option.fixedNumber"@realTime="realTime"@imgLoad="imgLoad"style="width: 100%; height: 400px;"></vue-cropper><!-- 控制按钮 --><div class="btn-group"><button @click="startCrop">开始裁剪</button><button @click="stopCrop">停止裁剪</button><button @click="clearCrop">清除裁剪</button><button @click="changeScale(1)">放大</button><button @click="changeScale(-1)">缩小</button><button @click="rotateLeft">左旋转</button><button @click="rotateRight">右旋转</button><button @click="getCropData">获取裁剪结果</button></div><!-- 实时预览 --><div class="preview-box"><div class="preview" :style="previews.div"><img :src="previews.url" :style="previews.img"></div></div></div>
</template><script>
import VueCropper from 'vue-cropper'export default {name: 'CropperDemo',components: {VueCropper},data() {return {option: {img: '/path/to/your/image.jpg',  // 裁剪图片的地址outputSize: 1,         // 裁剪生成图片的质量(0.1-1)outputType: 'jpeg',    // 裁剪生成图片的格式info: true,           // 显示裁剪框的大小信息canScale: true,       // 图片是否允许滚轮缩放autoCrop: true,       // 是否默认生成截图框autoCropWidth: 300,   // 默认生成截图框宽度autoCropHeight: 200,  // 默认生成截图框高度fixed: true,          // 是否开启截图框宽高固定比例fixedNumber: [3, 2],  // 截图框的宽高比例},previews: {}}},methods: {// 实时预览realTime(data) {this.previews = data},// 图片加载完成imgLoad(msg) {console.log('图片加载:', msg)},// 开始裁剪startCrop() {this.$refs.cropper.startCrop()},// 停止裁剪stopCrop() {this.$refs.cropper.stopCrop()},// 清除裁剪clearCrop() {this.$refs.cropper.clearCrop()},// 缩放changeScale(num) {this.$refs.cropper.changeScale(num)},// 左旋转rotateLeft() {this.$refs.cropper.rotateLeft()},// 右旋转rotateRight() {this.$refs.cropper.rotateRight()},// 获取裁剪结果getCropData() {// 获取base64数据this.$refs.cropper.getCropData((data) => {console.log('Base64结果:', data)})// 获取blob数据this.$refs.cropper.getCropBlob((data) => {console.log('Blob结果:', data)})}}
}
</script><style scoped>
.cropper-container {max-width: 800px;margin: 0 auto;
}.btn-group {margin: 20px 0;text-align: center;
}.btn-group button {margin: 0 5px;padding: 8px 16px;background: #007bff;color: white;border: none;border-radius: 4px;cursor: pointer;
}.btn-group button:hover {background: #0056b3;
}.preview-box {margin-top: 20px;
}.preview {width: 200px;height: 133px;overflow: hidden;border: 1px solid #ccc;margin: 0 auto;
}
</style>

⚙️ 配置选项详解

基础配置

参数说明类型默认值可选值
img裁剪图片的地址Stringurl地址、base64、blob
outputSize裁剪生成图片的质量Number10.1 ~ 1
outputType裁剪生成图片的格式Stringjpgjpeg、png、webp
info图片的信息展示Booleantruetrue、false
canScale图片是否允许滚轮缩放Booleantruetrue、false

裁剪框配置

参数说明类型默认值可选值
autoCrop是否默认生成截图框Booleanfalsetrue、false
autoCropWidth默认生成截图框宽度Number容器的80%0 ~ max
autoCropHeight默认生成截图框高度Number容器的80%0 ~ max
fixed是否开启截图框宽高固定比例Booleanfalsetrue、false
fixedNumber截图框的宽高比例Array[1, 1][宽度, 高度]
fixedBox固定截图框大小不允许改变Booleanfalsetrue、false
centerBox截图框是否被限制在图片里面Booleanfalsetrue、false

交互配置

参数说明类型默认值可选值
canMove上传图片是否可以移动Booleantruetrue、false
canMoveBox截图框能否拖动Booleantruetrue、false
original上传图片按照原始比例渲染Booleanfalsetrue、false
full是否输出原图比例的截图Booleanfalsetrue、false
high是否按照设备的dpr输出等比例图片Booleantruetrue、false

高级配置

参数说明类型默认值可选值
infoTruetrue为展示真实输出图片宽高,false展示看到的截图框宽高Booleanfalsetrue、false
maxImgSize限制图片最大宽度和高度Number20000 ~ max
enlarge图片根据截图框输出比例倍数Number10 ~ max
mode图片默认渲染方式Stringcontaincontain、cover、100px、100% auto
limitMinSize裁剪框限制最小区域Number/Array/String10Number、Array、String
fillColor导出时背景颜色填充String#ffffff、white

🔄 回调方法

@realTime 实时预览事件

methods: {realTime(data) {console.log('实时预览数据:', data)/*data 包含以下属性:{img: '...',     // 裁剪的图片base64w: 200,         // 裁剪框宽度h: 100,         // 裁剪框高度div: {...},     // 预览容器样式url: '...'      // 图片地址}*/// 设置预览样式this.previews = data// 自定义预览大小this.previewStyle1 = {width: data.w + 'px',height: data.h + 'px',overflow: 'hidden',margin: '0',zoom: 0.5  // 缩放比例}}
}

@imgMoving 图片移动回调

methods: {imgMoving(data) {console.log('图片移动:', data)/*data 包含:{moving: true,  // 是否在移动axis: {x1: 100,     // 左上角x坐标x2: 300,     // 右下角x坐标y1: 50,      // 左上角y坐标y2: 200      // 右下角y坐标}}*/}
}

@cropMoving 截图框移动回调

methods: {cropMoving(data) {console.log('截图框移动:', data)// 数据结构与imgMoving相同}
}

@imgLoad 图片加载回调

methods: {imgLoad(msg) {if (msg === 'success') {console.log('图片加载成功')} else {console.log('图片加载失败')}}
}

🛠️ 内置方法

裁剪控制方法

// 开始裁剪
this.$refs.cropper.startCrop()// 停止裁剪
this.$refs.cropper.stopCrop()// 清除裁剪框
this.$refs.cropper.clearCrop()// 自动生成截图框
this.$refs.cropper.goAutoCrop()

图片操作方法

// 缩放图片 (正数放大,负数缩小)
this.$refs.cropper.changeScale(1)   // 放大
this.$refs.cropper.changeScale(-1)  // 缩小// 旋转图片
this.$refs.cropper.rotateLeft()   // 左旋转90度
this.$refs.cropper.rotateRight()  // 右旋转90度

获取坐标信息

// 获取图片基于容器的坐标点
const imgAxis = this.$refs.cropper.getImgAxis()// 获取截图框基于容器的坐标点
const cropAxis = this.$refs.cropper.getCropAxis()// 获取截图框宽高
const cropW = this.$refs.cropper.cropW
const cropH = this.$refs.cropper.cropH

获取裁剪结果

// 获取base64格式
this.$refs.cropper.getCropData((data) => {console.log('Base64数据:', data)// 可以直接用于img标签的srcthis.resultImg = data
})// 获取blob格式
this.$refs.cropper.getCropBlob((data) => {console.log('Blob数据:', data)// 可以用于FormData上传const formData = new FormData()formData.append('file', data, 'cropped.jpg')
})

🎨 实际应用案例

案例1:头像上传裁剪

<template><div class="avatar-upload"><!-- 文件选择 --><input type="file" ref="fileInput"@change="handleFileChange"accept="image/*"style="display: none"><!-- 当前头像展示 --><div class="current-avatar" @click="selectFile"><img v-if="avatarUrl" :src="avatarUrl" alt="头像"><div v-else class="avatar-placeholder">点击上传头像</div></div><!-- 裁剪弹窗 --><div v-if="showCropper" class="cropper-modal"><div class="cropper-content"><h3>裁剪头像</h3><vue-cropperref="cropper":img="tempImage":outputSize="1":outputType="'jpeg'":autoCrop="true":autoCropWidth="200":autoCropHeight="200":fixed="true":fixedNumber="[1, 1]":centerBox="true"style="width: 100%; height: 400px;"></vue-cropper><div class="cropper-buttons"><button @click="cancelCrop">取消</button><button @click="confirmCrop">确认</button></div></div></div></div>
</template><script>
export default {data() {return {avatarUrl: '',tempImage: '',showCropper: false}},methods: {selectFile() {this.$refs.fileInput.click()},handleFileChange(e) {const file = e.target.files[0]if (!file) return// 验证文件类型if (!file.type.startsWith('image/')) {alert('请选择图片文件')return}// 验证文件大小 (5MB)if (file.size > 5 * 1024 * 1024) {alert('图片大小不能超过5MB')return}// 读取文件并显示裁剪器const reader = new FileReader()reader.onload = (e) => {this.tempImage = e.target.resultthis.showCropper = true}reader.readAsDataURL(file)},cancelCrop() {this.showCropper = falsethis.tempImage = ''this.$refs.fileInput.value = ''},confirmCrop() {this.$refs.cropper.getCropBlob((blob) => {// 上传到服务器this.uploadAvatar(blob)})},async uploadAvatar(blob) {const formData = new FormData()formData.append('avatar', blob, 'avatar.jpg')try {const response = await fetch('/api/upload-avatar', {method: 'POST',body: formData})const result = await response.json()if (result.success) {this.avatarUrl = result.urlthis.showCropper = falsethis.tempImage = ''alert('头像上传成功')}} catch (error) {console.error('上传失败:', error)alert('上传失败,请重试')}}}
}
</script><style scoped>
.current-avatar {width: 100px;height: 100px;border-radius: 50%;overflow: hidden;cursor: pointer;border: 2px solid #ddd;display: flex;align-items: center;justify-content: center;
}.current-avatar img {width: 100%;height: 100%;object-fit: cover;
}.avatar-placeholder {color: #999;font-size: 12px;text-align: center;
}.cropper-modal {position: fixed;top: 0;left: 0;right: 0;bottom: 0;background: rgba(0, 0, 0, 0.8);display: flex;align-items: center;justify-content: center;z-index: 1000;
}.cropper-content {background: white;padding: 20px;border-radius: 8px;width: 90%;max-width: 600px;
}.cropper-buttons {margin-top: 20px;text-align: center;
}.cropper-buttons button {margin: 0 10px;padding: 8px 20px;border: none;border-radius: 4px;cursor: pointer;
}
</style>

案例2:商品图片批量裁剪

<template><div class="batch-cropper"><h2>商品图片批量裁剪</h2><!-- 上传区域 --><div class="upload-area" @drop="handleDrop" @dragover.prevent><input type="file" ref="fileInput"@change="handleFileSelect"multipleaccept="image/*"style="display: none"><button @click="selectFiles">选择图片</button><p>或拖拽图片到此区域</p></div><!-- 图片列表 --><div class="image-list"><div v-for="(item, index) in imageList" :key="index"class="image-item":class="{ active: currentIndex === index }"@click="selectImage(index)"><img :src="item.preview" alt=""><div class="image-status"><span v-if="item.cropped" class="status-success">✓</span><span v-else class="status-pending">○</span></div></div></div><!-- 裁剪区域 --><div v-if="currentImage" class="cropper-area"><vue-cropperref="cropper":img="currentImage.src":outputSize="0.8":outputType="'jpeg'":autoCrop="true":autoCropWidth="300":autoCropHeight="300":fixed="true":fixedNumber="[1, 1]"style="width: 100%; height: 400px;"></vue-cropper><div class="cropper-controls"><button @click="prevImage" :disabled="currentIndex === 0">上一张</button><button @click="cropCurrent">裁剪当前图片</button><button @click="nextImage" :disabled="currentIndex === imageList.length - 1">下一张</button><button @click="batchCrop" class="batch-btn">批量裁剪</button></div></div><!-- 结果展示 --><div v-if="croppedImages.length" class="results"><h3>裁剪结果</h3><div class="result-grid"><div v-for="(result, index) in croppedImages" :key="index" class="result-item"><img :src="result.url" alt=""><button @click="downloadImage(result, index)">下载</button></div></div></div></div>
</template><script>
export default {data() {return {imageList: [],currentIndex: 0,croppedImages: []}},computed: {currentImage() {return this.imageList[this.currentIndex] || null}},methods: {selectFiles() {this.$refs.fileInput.click()},handleFileSelect(e) {this.processFiles(e.target.files)},handleDrop(e) {e.preventDefault()this.processFiles(e.dataTransfer.files)},processFiles(files) {Array.from(files).forEach(file => {if (file.type.startsWith('image/')) {const reader = new FileReader()reader.onload = (e) => {this.imageList.push({file,src: e.target.result,preview: e.target.result,cropped: false})}reader.readAsDataURL(file)}})},selectImage(index) {this.currentIndex = index},prevImage() {if (this.currentIndex > 0) {this.currentIndex--}},nextImage() {if (this.currentIndex < this.imageList.length - 1) {this.currentIndex++}},cropCurrent() {this.$refs.cropper.getCropData((data) => {this.croppedImages.push({url: data,originalIndex: this.currentIndex})this.imageList[this.currentIndex].cropped = true// 自动切换到下一张if (this.currentIndex < this.imageList.length - 1) {this.nextImage()}})},batchCrop() {const uncroppedImages = this.imageList.filter(item => !item.cropped)if (uncroppedImages.length === 0) {alert('所有图片都已裁剪完成')return}if (confirm(`还有${uncroppedImages.length}张图片未裁剪,是否使用当前设置批量裁剪?`)) {this.processBatchCrop()}},processBatchCrop() {// 这里可以实现批量裁剪逻辑// 由于vue-cropper需要逐个处理,这里示例批量应用相同设置alert('批量裁剪功能开发中...')},downloadImage(result, index) {const link = document.createElement('a')link.href = result.urllink.download = `cropped-image-${index + 1}.jpg`link.click()}}
}
</script><style scoped>
.upload-area {border: 2px dashed #ccc;padding: 40px;text-align: center;margin-bottom: 20px;border-radius: 8px;
}.upload-area:hover {border-color: #007bff;
}.image-list {display: flex;gap: 10px;margin-bottom: 20px;overflow-x: auto;
}.image-item {position: relative;width: 80px;height: 80px;cursor: pointer;border: 2px solid transparent;border-radius: 4px;
}.image-item.active {border-color: #007bff;
}.image-item img {width: 100%;height: 100%;object-fit: cover;border-radius: 4px;
}.image-status {position: absolute;top: -5px;right: -5px;width: 20px;height: 20px;border-radius: 50%;background: white;display: flex;align-items: center;justify-content: center;border: 1px solid #ccc;
}.status-success {color: green;
}.cropper-controls {margin-top: 20px;text-align: center;
}.cropper-controls button {margin: 0 5px;padding: 8px 16px;border: none;border-radius: 4px;cursor: pointer;
}.batch-btn {background: #28a745 !important;color: white;
}.results {margin-top: 40px;
}.result-grid {display: grid;grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));gap: 20px;
}.result-item {text-align: center;
}.result-item img {width: 100%;border-radius: 4px;border: 1px solid #ddd;
}
</style>

🔧 最佳实践

1. 性能优化

// 大图片预处理
methods: {async processLargeImage(file) {// 压缩图片尺寸const canvas = document.createElement('canvas')const ctx = canvas.getContext('2d')const img = new Image()return new Promise((resolve) => {img.onload = () => {const maxSize = 1920let { width, height } = imgif (width > maxSize || height > maxSize) {if (width > height) {height = (height * maxSize) / widthwidth = maxSize} else {width = (width * maxSize) / heightheight = maxSize}}canvas.width = widthcanvas.height = heightctx.drawImage(img, 0, 0, width, height)resolve(canvas.toDataURL('image/jpeg', 0.8))}img.src = URL.createObjectURL(file)})}
}

2. 移动端适配

/* 移动端样式 */
@media (max-width: 768px) {.vue-cropper {height: 300px !important;}.cropper-controls {display: flex;flex-direction: column;gap: 10px;}.cropper-controls button {width: 100%;padding: 12px;}
}

3. 错误处理

methods: {handleError(error) {console.error('裁剪错误:', error)// 用户友好的错误提示const errorMessages = {'file-too-large': '文件太大,请选择小于5MB的图片','invalid-format': '不支持的图片格式','crop-failed': '裁剪失败,请重试'}this.showMessage(errorMessages[error.type] || '操作失败,请重试')},showMessage(message) {// 实现消息提示alert(message)}
}

🎯 总结

Vue-Cropper 是一个功能强大的Vue图片裁剪组件,它提供了:

丰富的配置选项:满足各种裁剪需求
完整的API接口:支持所有常用操作
实时预览功能:提供良好的用户体验
多种输出格式:支持不同的应用场景
Vue2/Vue3兼容:适配不同版本的Vue项目
移动端友好:支持触摸操作和响应式设计

通过合理使用Vue-Cropper,您可以轻松实现头像上传、商品图片处理、证件照裁剪等功能,为用户提供专业的图片处理体验。


开始您的图片裁剪之旅吧! 📸

💡 开发建议:在实际项目中,建议结合文件上传、图片压缩、格式转换等功能,构建完整的图片处理流程。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.pswp.cn/web/82437.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

[Go] Option选项设计模式 — — 编程方式基础入门

[Go] Option选项设计模式 — — 编程方式基础入门 全部代码地址&#xff0c;欢迎⭐️ Github&#xff1a;https://github.com/ziyifast/ziyifast-code_instruction/tree/main/go-demo/go-option 1 介绍 在 Go 开发中&#xff0c;我们经常遇到需要处理多参数配置的场景。传统方…

【Unity开发】控制手机移动端的震动

&#x1f43e; 个人主页 &#x1f43e; 阿松爱睡觉&#xff0c;横竖醒不来 &#x1f3c5;你可以不屠龙&#xff0c;但不能不磨剑&#x1f5e1; 目录 一、前言二、Unity的Handheld.Vibrate()三、调用Android原生代码四、NiceVibrations插件五、DeviceVibration插件六、控制游戏手…

Linux 软件安装方式全解(适用于 CentOS/RHEL 系统)

&#x1f427; Linux 软件安装方式全解&#xff08;适用于 CentOS/RHEL 系统&#xff09; 在 Linux 系统中&#xff0c;软件安装方式丰富多样&#xff0c;常见于以下几种方式&#xff1a; 安装方式命令/工具说明软件包管理器&#xff08;推荐&#xff09;yum, dnf, apt, zypp…

前端面试题-HTML篇

1. 请谈谈你对 Web 标准以及 W3C 的理解和认识。 我对 Web 标准 的理解是,它就像是互联网世界的“交通规则”,由 W3C(World Wide Web Consortium,万维网联盟) 这样一个国际性组织制定。这些规则规范了我们在编写 HTML、CSS 和 JavaScript 时应该遵循的语法和行为,比如要…

ERROR: column cl.udt_name does not exist LINE 1 navicat打开金仓表报错

描述&#xff1a; ERROR: column cl.udt_name does not exist LINE 1: …a.columns cl LEFT JOlN pg type ty ON ty.typname cl.udt nam. navicat连上金仓数据库之后&#xff0c;想打开一张表看看&#xff0c;每张表都报这个错&#xff0c;打不开 解决方案&#xff1a; 网上…

2025年- H61-Lc169--74.搜索二维矩阵(二分查找)--Java版

1.题目描述 2.思路 方法一&#xff1a; 定义其实坐标&#xff0c;右上角的元素&#xff08;0&#xff0c;n-1&#xff09;。进入while循环&#xff08;注意边界条件&#xff0c;行数小于m&#xff0c;列数要&#xff1e;0&#xff09;从右上角开始开始向左遍历&#xff08;比当…

Jupyter MCP服务器部署实战:AI模型与Python环境无缝集成教程

Jupyter MCP 服务器是基于模型上下文协议&#xff08;Model Context Protocol, MCP&#xff09;的 Jupyter 环境扩展组件&#xff0c;它能够实现大型语言模型与实时编码会话的无缝集成。该服务器通过标准化的协议接口&#xff0c;使 AI 模型能够安全地访问和操作 Jupyter 的核心…

MySQL下载安装配置环境变量

MySQL下载安装配置环境变量 文章目录 MySQL下载安装配置环境变量一、安装MySQL1.1 下载1.2 安装 二、查看MySQL服务是否启动三、配置环境变量四、验证 一、安装MySQL 1.1 下载 官网社区版&#xff08;免费版&#xff09;&#xff1a;https://dev.mysql.com/downloads/mysql/ …

WSL 安装 Debian 12 后,Linux 如何安装 curl , quickjs ?

在 WSL 的 Debian 12 系统中安装 curl 非常简单&#xff0c;你可以直接使用 APT 包管理器从官方仓库安装。以下是详细步骤&#xff1a; 1. 更新软件包索引 首先确保系统的包索引是最新的&#xff1a; sudo apt update2. 安装 curl 执行以下命令安装 curl&#xff1a; sudo…

Linux入门(十四)rpmyum

RPM 是RedHat PackManager的缩写 rpm是用于互联网下载包的打包及安装工具 rpm查询 查询已安装的rpm列表 rpm -qa查看系统是否安装了psmisc rpm -qa | grep psmisc rpm -q psmisc查询软件包信息 rpm -qi psmisc查询软件包中的文件 rpm -ql psmisc根据文件全路径 查询文件所…

[git]忽略.gitignore文件

git rm --cached .gitignore 是一个 Git 命令,主要用于 从版本控制中移除已追踪的 .gitignore 文件,但保留该文件在本地工作目录中。以下是详细解析: 一、命令拆解与核心作用 语法解析 git rm:Git 的删除命令,用于从版本库(Repository)中移除文件。--cached:关键参数…

Hive SQL 中 BY 系列关键字全解析:从排序、分发到分组的核心用法

一、排序与分发相关 BY 关键字 1. ORDER BY&#xff1a;全局统一排序 作用&#xff1a;对查询结果进行全局排序&#xff0c;确保最终结果集完全有序&#xff08;仅允许单个 Reducer 处理数据&#xff09;。 语法&#xff1a; SELECT * FROM table_name ORDER BY column1 [A…

网络爬虫 - App爬虫及代理的使用(十一)

App爬虫及代理的使用 一、App抓包1. App爬虫原理2. reqable的安装与配置1. reqable安装教程2. reqable的配置3. 模拟器的安装与配置1. 夜神模拟器的安装2. 夜神模拟器的配置4. 内联调试及注意事项1. 软件启动顺序2. 开启抓包功能3. reqable面板功能4. 夜神模拟器设置项5. 注意事…

【25.06】FISCOBCOS使用caliper自定义测试 通过webase 单机四节点 helloworld等进行测试

前置条件 安装一个Ubuntu20+的镜像 基础环境安装 Git cURL vim jq sudo apt install -y git curl vim jq Docker和Docker-compose 这个命令会自动安装docker sudo apt install docker-compose sudo chmod +x /usr/bin/docker-compose docker versiondocker-compose vers…

【基础】Unity中Camera组件知识点

一、投影模式 (Projection) 1. 透视模式 (Perspective) 原理&#xff1a;模拟人眼&#xff0c;近大远小&#xff08;锥形体视锥&#xff09; 核心参数&#xff1a; Field of View (FOV)&#xff1a;垂直视场角 典型值&#xff1a;第一人称 60-90&#xff0c;驾驶舱 30-45 特…

PCA(K-L变换)人脸识别(python实现)

数据集分析 ORL数据集&#xff0c; 总共40个人&#xff0c;每个人拍摄10张人脸照片 照片格式为灰度图像&#xff0c;尺寸112 * 92 特点&#xff1a; 图像质量高&#xff0c;无需灰度运算、去噪等预处理 人脸已经位于图像正中央&#xff0c;但部分图像角度倾斜&#xff08;可…

【Git】View Submitted Updates——diff、show、log

在 Git 中查看更新的内容&#xff08;即工作区、暂存区或提交之间的差异&#xff09;是日常开发中的常见操作。以下是常用的命令和场景说明&#xff1a; 文章目录 1、查看工作区与暂存区的差异2、查看提交历史中的差异3、查看工作区与最新提交的差异4、查看两个提交之间的差异5…

deepseek原理和项目实战笔记2 -- deepseek核心架构

混合专家&#xff08;MoE&#xff09; ​​混合专家&#xff08;Mixture of Experts, MoE&#xff09;​​ 是一种机器学习模型架构&#xff0c;其核心思想是通过组合多个“专家”子模型&#xff08;通常为小型神经网络&#xff09;来处理不同输入&#xff0c;从而提高模型的容…

GPU层次结构(Nvidia和Apple M芯片,从硬件到pytorch)

这里写目录标题 0、驱动pytorch环境安装验证1.window环境2.Mac Apple M芯片环境 1、Nvidia显卡驱动、CUDA、cuDNN关系汇总1**1. Nvidia显卡驱动&#xff08;Graphics Driver&#xff09;****2. CUDA&#xff08;Compute Unified Device Architecture&#xff09;****3. cuDNN&a…

OpenWrt 搭建 samba 服务器的方法并解决 Windows 不允许访问匿名服务器(0x80004005的错误)的方法

文章目录 一、安装所需要的软件二、配置自动挂载三、配置 Samba 服务器四、配置 Samba 访问用户和密码&#xff08;可选&#xff09;新建 Samba 专门的用户添加无密码的 Samba 账户使用root账户 五、解决 Windows 无法匿名访问Samba方案一 配置无密码的Samba账户并启用匿名访问…