
AI
PIL 库:
Python

Python
# 打开图像文件并更改大小
im = Image.open("example.jpg")
new_size = (800, 600)
im_resized = im.resize(new_size)
# 显示修改后的图像
im_resized.show()
MATLAB 中的图像处理工具箱:
matlab
% 读取图像并更改大小
im = imread('example.jpg');
new_size = [600 800];
im_resized = imresize(im, new_size);
% 显示修改后的图像
imshow(im_resized);
如果您是使用基于视觉的 AI 工具(如 TensorFlow.JS 或 PyTorch),则需要使用不同的 API。例如,使用 TensorFlow.JS:
Javascript
// 加载图像并修改大小
const img = new Image();
img.src = 'example.jpg';
img.width = 800;
img.height = 600;
// 在画布上绘制图像
const canvas = document.getElementById('canvas');
const ctx = canvas.getcontext('2d');
ctx.drawImage(img, 0, 0);
Copyright © 2025 IZhiDa.com All Rights Reserved.
知答 版权所有 粤ICP备2023042255号