使用 HTML + JavaScript 实现图片裁剪上传功能

article/2025/7/15 8:17:41

本文将详细介绍一个基于 HTML 和 JavaScript 实现的图片裁剪上传功能。该功能支持文件选择、拖放上传、图片预览、区域选择、裁剪操作以及图片下载等功能,适用于需要进行图片处理的 Web 应用场景。

效果演示

image-20250602112435691

image-20250602112543017

项目概述

本项目主要包含以下核心功能:

  • 文件选择与拖放上传
  • 裁剪框拖动与调整大小
  • 图片裁剪
  • 图片上传(模拟)与下载

页面结构

上传区域

实现友好的文件选择体验,并支持拖放上传。

<div class="upload-section"><input type="file" id="fileInput" accept="image/*"><label for="fileInput" class="file-label">选择图片</label><p>或拖放图片到此处</p>
</div>
预览区域

分为两个部分,左侧显示原始图片和裁剪框,右侧展示裁剪后的结果。

<div class="preview-section"><div class="image-container"><div><h3>原始图片</h3><img id="originalImage" style="max-width: 100%; display: none;"><div class="cropper-container" id="cropperContainer" style="display: none;"><canvas id="sourceCanvas"></canvas><div class="selection-box" id="selectionBox"><div class="resize-handle"></div></div></div><p class="instruction">拖动选择框可移动位置,拖动右下角可调整大小</p></div><div><h3>裁剪结果</h3><canvas id="croppedCanvas" style="display: none;"></canvas><p id="noCropMessage">请先选择图片并设置裁剪区域</p></div></div>
</div>
操作按钮

提供“裁剪”、“上传”、“下载”和“重置”按钮,方便用户进行各种操作。

<div class="controls"><button id="cropBtn" disabled>裁剪图片</button><button id="uploadBtn" disabled>上传图片</button><button id="downloadBtn" disabled>下载图片</button><button id="resetBtn">重置</button>
</div>

核心功能实现

定义基础变量

获取DOM元素

const fileInput = document.getElementById('fileInput');
const originalImage = document.getElementById('originalImage');
const sourceCanvas = document.getElementById('sourceCanvas');
const croppedCanvas = document.getElementById('croppedCanvas');
const cropperContainer = document.getElementById('cropperContainer');
const selectionBox = document.getElementById('selectionBox');
const cropBtn = document.getElementById('cropBtn');
const uploadBtn = document.getElementById('uploadBtn');
const resetBtn = document.getElementById('resetBtn');
const noCropMessage = document.getElementById('noCropMessage');
const downloadBtn = document.getElementById('downloadBtn');

定义全局变量

let isDragging = false;
let isResizing = false;
let startX, startY;
let selection = {x: 0,y: 0,width: 0,height: 0,startX: 0,startY: 0,startWidth: 0,startHeight: 0
};
let imageRatio = 1;
文件选择

使用 FileReader API 将选中的图片读取为 Data URL 并显示在页面上。

function handleFileSelect(event) {const file = event.target.files[0];if (!file || !file.type.match('image.*')) {alert('请选择有效的图片文件');return;}const reader = new FileReader();reader.onload = function(e) {originalImage.src = e.target.result;originalImage.onload = function() {initCropper();};};reader.readAsDataURL(file);
}
拖放上传

通过监听 dragover、dragleave 和 drop 事件实现拖放上传功能。

const uploadSection = document.querySelector('.upload-section');
uploadSection.addEventListener('dragover', (e) => {e.preventDefault();uploadSection.style.borderColor = '#4CAF50';
});uploadSection.addEventListener('dragleave', () => {uploadSection.style.borderColor = '#ccc';
});uploadSection.addEventListener('drop', (e) => {e.preventDefault();uploadSection.style.borderColor = '#ccc';if (e.dataTransfer.files.length) {fileInput.files = e.dataTransfer.files;handleFileSelect({ target: fileInput });}
});
图片预览与裁剪框初始化

在图片加载完成后,绘制到 canvas 上,并根据图片尺寸调整画布大小。初始化一个固定比例的裁剪框,居中显示在画布上。

function initCropper() {// 显示原始图片和裁剪区域originalImage.style.display = 'none';cropperContainer.style.display = 'inline-block';// 设置canvas尺寸const maxWidth = 500;imageRatio = originalImage.naturalWidth / originalImage.naturalHeight;let canvasWidth, canvasHeight;if (originalImage.naturalWidth > maxWidth) {canvasWidth = maxWidth;canvasHeight = maxWidth / imageRatio;} else {canvasWidth = originalImage.naturalWidth;canvasHeight = originalImage.naturalHeight;}sourceCanvas.width = canvasWidth;sourceCanvas.height = canvasHeight;// 绘制图片到canvasconst ctx = sourceCanvas.getContext('2d');ctx.drawImage(originalImage, 0, 0, canvasWidth, canvasHeight);// 初始化选择框 (1:1比例)const boxSize = Math.min(canvasWidth, canvasHeight) * 0.6;selection = {x: Math.max(0, Math.min((canvasWidth - boxSize) / 2, canvasWidth - boxSize)), // 确保初始位置在画布范围内y: Math.max(0, Math.min((canvasHeight - boxSize) / 2, canvasHeight - boxSize)), // 确保初始位置在画布范围内width: boxSize,height: boxSize,startX: 0,startY: 0,startWidth: 0,startHeight: 0};updateSelectionBox();cropBtn.disabled = false;
}
裁剪框拖动与调整大小

通过监听鼠标事件(mousedown、mousemove、mouseup)实现裁剪框的拖动和调整大小功能。确保裁剪框始终位于画布范围内,并保持指定的比例。

selectionBox.addEventListener('mousedown', startDrag);
document.addEventListener('mousemove', handleDrag);
document.addEventListener('mouseup', endDrag);
const resizeHandle = document.querySelector('.resize-handle');
resizeHandle.addEventListener('mousedown', (e) => {e.stopPropagation();startResize(e);
});
function startDrag(e) {if (e.target.classList.contains('resize-handle')) {return; // 忽略调整大小手柄的点击}isDragging = true;startX = e.clientX;startY = e.clientY;// 存储初始位置selection.startX = selection.x;selection.startY = selection.y;e.preventDefault();
}
function startResize(e) {isResizing = true;startX = e.clientX;startY = e.clientY;// 存储初始尺寸和位置selection.startX = selection.x;selection.startY = selection.y;selection.startWidth = selection.width;selection.startHeight = selection.height;e.preventDefault();
}
function handleDrag(e) {if (!isDragging && !isResizing) return;const dx = e.clientX - startX;const dy = e.clientY - startY;if (isDragging) {// 处理移动选择框let newX = selection.startX + dx;let newY = selection.startY + dy;// 限制在canvas范围内newX = Math.max(0, Math.min(newX, sourceCanvas.width - selection.width));newY = Math.max(0, Math.min(newY, sourceCanvas.height - selection.height));selection.x = newX;selection.y = newY;} else if (isResizing) {// 处理调整大小 (保持1:1比例)let newSize = Math.max(10, Math.min(selection.startWidth + (dx + dy) / 2, // 取dx和dy的平均值使调整更平滑Math.min(sourceCanvas.width - selection.startX,sourceCanvas.height - selection.startY)));// 应用新尺寸 (保持正方形)selection.width = newSize;selection.height = newSize;// 确保裁剪框不会超出画布范围if (selection.x + selection.width > sourceCanvas.width) {selection.x = sourceCanvas.width - selection.width;}if (selection.y + selection.height > sourceCanvas.height) {selection.y = sourceCanvas.height - selection.height;}}updateSelectionBox();
}
function endDrag() {isDragging = false;isResizing = false;
}
图片裁剪与结果展示

使用 drawImage 方法从源画布中裁剪出指定区域,并将其绘制到目标画布上。

function cropImage() {const ctx = croppedCanvas.getContext('2d');// 设置裁剪后canvas的尺寸 (1:1)croppedCanvas.width = selection.width;croppedCanvas.height = selection.height;// 执行裁剪ctx.drawImage(sourceCanvas,selection.x, selection.y, selection.width, selection.height, // 源图像裁剪区域0, 0, selection.width, selection.height                     // 目标canvas绘制区域);// 显示裁剪结果croppedCanvas.style.display = 'block';noCropMessage.style.display = 'none';uploadBtn.disabled = false;downloadBtn.disabled = false;
}
图片上传与下载

提供模拟的上传功能,使用 toBlob 方法获取裁剪后的图片数据。支持将裁剪后的图片下载为 JPEG 格式的文件。

function uploadImage() {// 在实际应用中,这里应该将图片数据发送到服务器croppedCanvas.toBlob((blob) => {// 创建FormData对象并添加图片const formData = new FormData();formData.append('croppedImage', blob, 'cropped-image.jpg');// 模拟上传延迟setTimeout(() => {alert('图片上传成功!(模拟)');console.log('上传的图片数据:', blob);// 在实际应用中,你可能需要处理服务器响应}, 1000);}, 'image/jpeg', 0.9);
}
function downloadImage() {if (!croppedCanvas.width || !croppedCanvas.height) {alert('请先裁剪图片');return;}// 创建一个临时的a标签用于触发下载const link = document.createElement('a');link.href = croppedCanvas.toDataURL('image/jpeg', 0.9);link.download = 'cropped-image.jpg'; // 设置下载文件名link.click();
}

扩展建议

  • 支持多种裁剪比例:可以扩展代码以支持不同的裁剪比例(如 4:3、16:9),并通过 UI 控件让用户选择。
  • 图像缩放功能:添加对图片缩放的支持,允许用户放大或缩小图片以便更精确地选择裁剪区域。
  • 服务器端集成:实际应用中,应将裁剪后的图片发送到服务器进行存储和处理,可以通过请求实现。

完整代码

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>图片裁剪上传</title><style>body {max-width: 1200px;margin: 0 auto;padding: 20px;}.container {display: flex;flex-direction: column;gap: 20px;}h1 {text-align: center;}.upload-section {padding: 20px;text-align: center;border-radius: 5px;background: #f8f9fa;border: 2px dashed #dee2e6;transition: all 0.3s ease;cursor: pointer;}.upload-section:hover {border-color: #4CAF50;background: rgba(76, 175, 80, 0.05);}.file-label {background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);color: white;border-radius: 25px;padding: 12px 24px;transition: transform 0.2s;}.file-label:hover {transform: translateY(-2px);box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);}.preview-section {display: flex;flex-direction: column;gap: 20px;background: #ffffff;border-radius: 12px;padding: 20px;box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);}canvas {max-width: 100%;border: 1px solid #eee;display: block;}.cropper-container {position: relative;display: inline-block;}.selection-box {position: absolute;border: 2px dashed #000;background: rgba(255, 255, 255, 0.3);cursor: move;box-sizing: border-box;}.resize-handle {position: absolute;width: 10px;height: 10px;background: #fff;border: 2px solid #000;border-radius: 50%;bottom: -5px;right: -5px;cursor: se-resize;}button {padding: 10px 15px;background-color: #4CAF50;color: white;border: none;border-radius: 4px;cursor: pointer;font-size: 16px;}button:hover {background-color: #45a049;}button {background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);border-radius: 25px;padding: 12px 24px;font-weight: 500;box-shadow: 0 4px 6px rgba(76, 175, 80, 0.1);transition: all 0.3s ease;}button:hover {transform: translateY(-2px);box-shadow: 0 6px 12px rgba(76, 175, 80, 0.2);}button:disabled {opacity: 0.6;cursor: not-allowed;}input[type="file"] {display: none;}.file-label {display: inline-block;padding: 10px 15px;background-color: #f0f0f0;border-radius: 4px;cursor: pointer;margin-bottom: 10px;}.controls {display: flex;gap: 10px;margin-top: 10px;justify-content: center;}.instruction {font-size: 14px;color: #666;margin-top: 10px;}.image-container {display: flex;gap: 20px;}.image-container > div {width: 500px;}</style>
</head>
<body>
<div class="container"><h1>图片裁剪上传</h1><div class="upload-section"><input type="file" id="fileInput" accept="image/*"><label for="fileInput" class="file-label">选择图片</label><p>或拖放图片到此处</p></div><div class="preview-section"><div class="image-container"><div><h3>原始图片</h3><img id="originalImage" style="max-width: 100%; display: none;"><div class="cropper-container" id="cropperContainer" style="display: none;"><canvas id="sourceCanvas"></canvas><div class="selection-box" id="selectionBox"><div class="resize-handle"></div></div></div><p class="instruction">拖动选择框可移动位置,拖动右下角可调整大小</p></div><div><h3>裁剪结果</h3><canvas id="croppedCanvas" style="display: none;"></canvas><p id="noCropMessage">请先选择图片并设置裁剪区域</p></div></div></div><div class="controls"><button id="cropBtn" disabled>裁剪图片</button><button id="uploadBtn" disabled>上传图片</button><button id="downloadBtn" disabled>下载图片</button><button id="resetBtn">重置</button></div>
</div><script>// 获取DOM元素const fileInput = document.getElementById('fileInput');const originalImage = document.getElementById('originalImage');const sourceCanvas = document.getElementById('sourceCanvas');const croppedCanvas = document.getElementById('croppedCanvas');const cropperContainer = document.getElementById('cropperContainer');const selectionBox = document.getElementById('selectionBox');const cropBtn = document.getElementById('cropBtn');const uploadBtn = document.getElementById('uploadBtn');const resetBtn = document.getElementById('resetBtn');const noCropMessage = document.getElementById('noCropMessage');const downloadBtn = document.getElementById('downloadBtn');// 全局变量let isDragging = false;let isResizing = false;let startX, startY;let selection = {x: 0,y: 0,width: 0,height: 0,startX: 0,startY: 0,startWidth: 0,startHeight: 0};let imageRatio = 1;// 监听文件选择fileInput.addEventListener('change', handleFileSelect);// 拖放功能const uploadSection = document.querySelector('.upload-section');uploadSection.addEventListener('dragover', (e) => {e.preventDefault();uploadSection.style.borderColor = '#4CAF50';});uploadSection.addEventListener('dragleave', () => {uploadSection.style.borderColor = '#ccc';});uploadSection.addEventListener('drop', (e) => {e.preventDefault();uploadSection.style.borderColor = '#ccc';if (e.dataTransfer.files.length) {fileInput.files = e.dataTransfer.files;handleFileSelect({ target: fileInput });}});// 选择框鼠标事件selectionBox.addEventListener('mousedown', startDrag);document.addEventListener('mousemove', handleDrag);document.addEventListener('mouseup', endDrag);// 调整大小手柄事件const resizeHandle = document.querySelector('.resize-handle');resizeHandle.addEventListener('mousedown', (e) => {e.stopPropagation();startResize(e);});// 下载图片function downloadImage() {if (!croppedCanvas.width || !croppedCanvas.height) {alert('请先裁剪图片');return;}// 创建一个临时的a标签用于触发下载const link = document.createElement('a');link.href = croppedCanvas.toDataURL('image/jpeg', 0.9);link.download = 'cropped-image.jpg'; // 设置下载文件名link.click();}// 按钮事件cropBtn.addEventListener('click', cropImage);uploadBtn.addEventListener('click', uploadImage);resetBtn.addEventListener('click', resetAll);downloadBtn.addEventListener('click', downloadImage);// 处理文件选择function handleFileSelect(event) {const file = event.target.files[0];if (!file || !file.type.match('image.*')) {alert('请选择有效的图片文件');return;}const reader = new FileReader();reader.onload = function(e) {originalImage.src = e.target.result;originalImage.onload = function() {initCropper();};};reader.readAsDataURL(file);}// 初始化裁剪器function initCropper() {// 显示原始图片和裁剪区域originalImage.style.display = 'none';cropperContainer.style.display = 'inline-block';// 设置canvas尺寸const maxWidth = 500;imageRatio = originalImage.naturalWidth / originalImage.naturalHeight;let canvasWidth, canvasHeight;if (originalImage.naturalWidth > maxWidth) {canvasWidth = maxWidth;canvasHeight = maxWidth / imageRatio;} else {canvasWidth = originalImage.naturalWidth;canvasHeight = originalImage.naturalHeight;}sourceCanvas.width = canvasWidth;sourceCanvas.height = canvasHeight;// 绘制图片到canvasconst ctx = sourceCanvas.getContext('2d');ctx.drawImage(originalImage, 0, 0, canvasWidth, canvasHeight);// 初始化选择框 (1:1比例)const boxSize = Math.min(canvasWidth, canvasHeight) * 0.6;selection = {x: Math.max(0, Math.min((canvasWidth - boxSize) / 2, canvasWidth - boxSize)), // 确保初始位置在画布范围内y: Math.max(0, Math.min((canvasHeight - boxSize) / 2, canvasHeight - boxSize)), // 确保初始位置在画布范围内width: boxSize,height: boxSize,startX: 0,startY: 0,startWidth: 0,startHeight: 0};updateSelectionBox();cropBtn.disabled = false;}// 更新选择框位置和尺寸function updateSelectionBox() {selectionBox.style.left = `${selection.x}px`;selectionBox.style.top = `${selection.y}px`;selectionBox.style.width = `${selection.width}px`;selectionBox.style.height = `${selection.height}px`;}// 开始拖动function startDrag(e) {if (e.target.classList.contains('resize-handle')) {return; // 忽略调整大小手柄的点击}isDragging = true;startX = e.clientX;startY = e.clientY;// 存储初始位置selection.startX = selection.x;selection.startY = selection.y;e.preventDefault();}// 处理拖动function handleDrag(e) {if (!isDragging && !isResizing) return;const dx = e.clientX - startX;const dy = e.clientY - startY;if (isDragging) {// 处理移动选择框let newX = selection.startX + dx;let newY = selection.startY + dy;// 限制在canvas范围内newX = Math.max(0, Math.min(newX, sourceCanvas.width - selection.width));newY = Math.max(0, Math.min(newY, sourceCanvas.height - selection.height));selection.x = newX;selection.y = newY;} else if (isResizing) {// 处理调整大小 (保持1:1比例)let newSize = Math.max(10, Math.min(selection.startWidth + (dx + dy) / 2, // 取dx和dy的平均值使调整更平滑Math.min(sourceCanvas.width - selection.startX,sourceCanvas.height - selection.startY)));// 应用新尺寸 (保持正方形)selection.width = newSize;selection.height = newSize;// 确保裁剪框不会超出画布范围if (selection.x + selection.width > sourceCanvas.width) {selection.x = sourceCanvas.width - selection.width;}if (selection.y + selection.height > sourceCanvas.height) {selection.y = sourceCanvas.height - selection.height;}}updateSelectionBox();}// 结束拖动或调整大小function endDrag() {isDragging = false;isResizing = false;}// 开始调整大小function startResize(e) {isResizing = true;startX = e.clientX;startY = e.clientY;// 存储初始尺寸和位置selection.startX = selection.x;selection.startY = selection.y;selection.startWidth = selection.width;selection.startHeight = selection.height;e.preventDefault();}// 裁剪图片function cropImage() {const ctx = croppedCanvas.getContext('2d');// 设置裁剪后canvas的尺寸 (1:1)croppedCanvas.width = selection.width;croppedCanvas.height = selection.height;// 执行裁剪ctx.drawImage(sourceCanvas,selection.x, selection.y, selection.width, selection.height, // 源图像裁剪区域0, 0, selection.width, selection.height                     // 目标canvas绘制区域);// 显示裁剪结果croppedCanvas.style.display = 'block';noCropMessage.style.display = 'none';uploadBtn.disabled = false;downloadBtn.disabled = false;}// 上传图片function uploadImage() {// 在实际应用中,这里应该将图片数据发送到服务器croppedCanvas.toBlob((blob) => {// 创建FormData对象并添加图片const formData = new FormData();formData.append('croppedImage', blob, 'cropped-image.jpg');// 模拟上传延迟setTimeout(() => {alert('图片上传成功!(模拟)');console.log('上传的图片数据:', blob);// 在实际应用中,你可能需要处理服务器响应}, 1000);}, 'image/jpeg', 0.9);}// 重置所有function resetAll() {// 隐藏元素cropperContainer.style.display = 'none';croppedCanvas.style.display = 'none';noCropMessage.style.display = 'block';originalImage.style.display = 'none';// 重置按钮状态cropBtn.disabled = true;uploadBtn.disabled = true;downloadBtn.disabled = true;// 清除文件输入fileInput.value = '';// 清除画布const ctx = sourceCanvas.getContext('2d');ctx.clearRect(0, 0, sourceCanvas.width, sourceCanvas.height);const croppedCtx = croppedCanvas.getContext('2d');croppedCtx.clearRect(0, 0, croppedCanvas.width, croppedCanvas.height);}
</script>
</body>
</html>

http://www.hkcw.cn/article/YgbGkcZEvA.shtml

相关文章

【存储基础】存储设备和服务器的关系和区别

文章目录 1. 存储设备和服务器的区别2. 客户端访问数据路径场景1&#xff1a;经过服务器处理场景2&#xff1a;客户端直连 3. 服务器作为"中转站"的作用 刚开始接触存储的时候&#xff0c;以为数据都是存放在服务器上的&#xff0c;服务器和存储设备是一个东西&#…

SwinTransformer改进(13):融合CPCA注意力

1.创新点介绍 引言 本文将深入解析一个创新的CNN模型架构,它巧妙地将Swin Transformer与自定义的通道-位置交叉注意力(CPCA) 模块相结合。这种设计在保持Transformer强大特征提取能力的同时,通过注意力机制增强了模型对关键特征的聚焦能力。 1. CPCA注意力模块 class CP…

乌方提议6月底前俄乌进行下一轮谈判 等待俄方回应

6月2日,俄乌第二轮谈判在伊斯坦布尔的契拉昂宫举行。乌克兰国防部长乌梅罗夫表示,乌克兰提议在6月底之前再次与俄方会面,但俄方尚未对此做出回应。此次谈判由土耳其外长费丹主持。俄方代表团团长是俄总统助理梅金斯基,成员包括俄副外长加卢津、俄武装力量总参谋部总局局长科…

韩大选热度或打破纪录 政坛洗牌在即

韩国政坛即将迎来新一轮洗牌。6月3日,韩国将提前举行第21届总统选举。原定于2027年的大选因前总统尹锡悦在去年12月初发动戒严并于今年4月4日被弹劾而提前两年多举行。根据韩国宪法规定,总统被罢免后必须在6个月内举行总统选举。此次大选吸引了朝野两党的多位候选人参与,最终…

【LLM 指令遵循】论文分享:ULTRAIF

论文名称&#xff1a;UltraIF: Advancing Instruction Following from the Wild 论文链接&#xff1a;https://arxiv.org/abs/2502.04153 机构&#xff1a;上海AI Lab 北大 清华 Github代码链接&#xff1a;https://github.com/kkk-an/UltraIF 数据集链接&#xff1a;https:/…

Ruoyi AI 部署指南:从环境搭建到项目运行

目录 一、项目概述 二、环境准备 1. Java 开发环境 2. 数据库 3. 缓存系统 4. 构建工具 5. 前端工具 三、后端项目部署 1. 下载项目 2. 导入项目 安装jdk17后没有jre ​编辑 3. 配置 Maven 4. 初始化数据库 5. 启动 Redis 6. 启动项目 四、前端项目部署 1. 管…

凹凸工坊_AI手写模拟器|可打印的手写稿|免抄写的工具,抄写罚抄神器,一键生成手写文稿,模仿手写软件,在线手写字体转换器,手写模拟器APP下载,打印出以假乱真的模拟手写文档,模拟抄写软件

推荐这个非常好用的免费 ai 手写模拟器网站&#x1f50d;「凹凸工坊-手写转换」 地址&#xff1a;凹凸工坊_凹凸工坊-手写转换官网入口_一键生成手写文稿_手写模拟器_手写字体在线转换_在线字体制作_手写APP下载_模仿手写软件_AI手写字体生成_手写字体生成器_字体下载https://…

芝士ai系统,宝藏的论文查重降重经验!

完成一篇论文的辛苦工作后&#xff0c;面对高查重率无疑是令人沮丧的。但不必担忧&#xff0c;芝士AI降重工具可以助你一臂之力。本文将探讨芝士AI如何帮助学者们有效降低查重率&#xff0c;确保论文的原创性和学术价值。让我们一起看看芝士AI如何让学术写作变得更轻松。 芝士…

IDEA + DeepSeek 实现 AI辅助编程,提升效率10倍(全网超详细的终极图文实战指南)

前言 在软件开发的世界里&#xff0c;每个开发者都经历过这样的困境——在重复的CRUD代码中机械劳动&#xff0c;为复杂的业务逻辑调试数小时&#xff0c;或是在海量文档中寻找某个API的正确用法。传统的IDE工具虽能提供基础支持&#xff0c;却难以突破效率的“玻璃天花板”。而…

开启智慧之旅,AI与机器学习驱动的微服务设计模式探索

​🌈 个人主页:danci_ 🔥 系列专栏:《设计模式》 💪🏻 制定明确可量化的目标,坚持默默的做事。 🚀 转载自热榜文章🔥:探索设计模式的魅力:开启智慧之旅,AI与机器学习驱动的微服务设计模式探索(2024年04月21日 22:26:05目前全站综合热榜第三) ✨欢迎加入探索A…

探索GpuGeek:AI开发者与中小企业的算力宝藏平台

摘要&#xff1a;GpuGeek 作为面向 AI 开发者和中小企业的 AI 赋能平台&#xff0c;在 AI 时代具有重要意义。它提供丰富算力资源、多元框架工具等&#xff0c;涵盖深度学习项目、大模型研究等多方面&#xff0c;助力用户应对算力挑战&#xff0c;推动 AI 技术普及应用&#xf…

迁移学习:解锁AI高效学习与泛化能力的密钥

前言 在人工智能&#xff08;AI&#xff09;技术日新月异的今天&#xff0c;迁移学习&#xff08;Transfer Learning&#xff09;作为一项革命性技术&#xff0c;正深刻改变着机器学习领域的格局。 它不仅让模型能够像人类一样“举一反三”&#xff0c;更在加速模型开发、提升性…

王者归来!谷歌Gemini 2.5 Pro横扫全球AI榜单,国内用户终于可直接体验“最强大脑“

&#x1f31f; 嗨&#xff0c;我是Lethehong&#xff01;&#x1f31f; &#x1f30d; 立志在坚不欲说&#xff0c;成功在久不在速&#x1f30d; &#x1f680; 欢迎关注&#xff1a;&#x1f44d;点赞⬆️留言收藏&#x1f680; &#x1f340;欢迎使用&#xff1a;小智初学计…

AI图像编辑器 Luminar Neo 便携版 Win1.24.0.14794

如果你对图像编辑有兴趣&#xff0c;但又不想花费太多时间学习复杂的软件操作&#xff0c;那么 Luminar Neo 可能就是你要找的完美工具。作为一款基于AI技术的创意图像编辑器&#xff0c;Luminar Neo简化了复杂的编辑流程&#xff0c;即使是没有任何图像处理经验的新手&#xf…

win11系统安装踩坑笔记 u盘安装 2025

目录 试验1 系统之家下载的ghost&#xff0c;安装ok&#xff0c;不知道用户名密码 试验2 u盘安装 ok 试验3 硬盘安装 第1步&#xff0c;还在刚才网址上选择下载iso&#xff0c; 第2步&#xff0c;然后选择简体中文&#xff0c;然后会开始下载iso。 第3步&#xff0c;下载…

郑钦文:会拼到最后一刻 再战萨巴伦卡备受关注

北京时间6月2日凌晨,法网女单第四轮上半区四场比赛结束后,部分八强赛对阵揭晓。中国选手郑钦文将与世界第一萨巴伦卡交手,这是两人时隔半月后的再次对决,备受瞩目。郑钦文职业生涯首次打进法网女单八强。今年在澳网、迈阿密站、马德里站和罗马站等比赛中,郑钦文多次与萨巴…

乌宣称命中41架俄军机 俄方怎么说 筹备一年半行动

6月1日,乌克兰对俄罗斯境内多处军事设施发动无人机袭击。乌克兰国家安全局网站于2日下午发表声明,确认策划了代号为“蛛网”的特别行动,并声称击中包括A-50预警机、图-95轰炸机、图-22M3轰炸机和图-160轰炸机在内的41架俄军飞机。乌克兰国家安全局局长瓦西里马柳克表示,摧毁…

深圳北一无人认领行李箱内有87万现金 20分钟物归原主

端午假期期间,深圳北站迎来客流高峰,单日发送和到达旅客突破50万人次。在这繁忙的出行场景中,一个装有87万元现金的行李箱与主人意外分离。铁路工作人员迅速反应,仅用20分钟就让这笔巨款物归原主。在深圳北站服务台,两名失主与值班站长刘慧一同清点行李箱里的现金。5月31日…

苏超让常州火出圈了 赛事带动文旅消费

江苏省城市足球联赛在这个假期引起了广泛关注,甚至一度冲上热搜。网友们戏称这项赛事为“苏超”,不仅因为比赛精彩纷呈,还因为它带动了文旅消费,促进了城市间的交流。在南京市五台山体育馆举行的第三轮收官战中,南京主场对阵无锡的比赛吸引了15000余名球迷进场观赛。尽管下…

地磁暴带来哪些影响?卫星导航误差可能增大 北部有机会出现极光 太阳爆发耀斑引发

中国气象局国家空间天气监测预警中心报告,北京时间5月31日太阳爆发耀斑。地球可能连续三天发生地磁暴,我国北部有机会出现较为明显的极光。5月31日7点45分左右,太阳活动区14100开始爆发耀斑,软X射线流量快速上升,8点05分达到峰值——M8.1级中等耀斑强度。伴随耀斑的发生还…