ASP.NET Core SixLabors.ImageSharp v1.0 的图像实用程序类 web示例
这个小型实用程序库需要将 NuGet SixLabors.ImageSharp包(版本 1.0.4)添加到.NET Core 3.1/ .NET 6 / .NET 8项目中。它与Windows、Linux和 MacOS兼容。
这已针对 ImageSharp v3.0.1 进行了重新设计。
它可以根据百万像素数或长度乘以宽度来调整图像大小,并根据需要保留纵横比。
它根据EXIF数据旋转/翻转图像。这是为了适应移动设备。
它还创建散点图和直方图。
另请参阅:MVC 应用程序的位图图像创建和下载
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Formats.Png;
using System.IO;
using System;
using SixLabors.ImageSharp.Formats.Jpeg;
namespace ImageUtil
{
public class GetSize
{
public GetSize(Stream stream)
{
using (Image iOriginal = Image.Load(stream))
{
stream.Position = 0;
Width = iOriginal.Width;
Height = iOriginal.Height;
}
}
/// <summary>
/// The width of the image specified in the class constructor's Stream parameter
/// </summary>
public int Width { get; }
/// <summary>
/// The height of the image specified in the class constructor's Stream parameter
/// </summary>
public int Height { get; }
}
public static class Resize
{
/// <summary>
/// Resize and save an image to a Stream specifying its new width and height
/// </summary>
public static void SaveImage(Stream imageStream, int newWidth, int newHeight, bool preserveImageRatio, Stream saveToStream, int jpegQuality = 100)
{
using (Image iOriginal = Image.Load(imageStream))
{
imageStream.Position = 0;
if (preserveImageRatio)
{
float percentWidth = newWidth / (float)iOriginal.Width;
float percentHeight = newHeight / (float)iOriginal.Height;
float percent = percentHeight < percentWidth ? percentHeight : percentWidth;
newWidth = (int)Math.Round(iOriginal.Width * percent, 0);
newHeight = (int)Math.Round(iOriginal.Height * percent, 0);
}
resize(imageStream, iOriginal, newWidth, newHeight, saveToStream, jpegQuality);
}
}
/// <summary>
/// Resize and save an image to a Stream specifying the number of pixels to resize to
/// </summary>
public static void SaveImage(Stream imageStream, int newNumberOfPixels, Stream saveToStream, int jpegQuality = 100)
{
using (Image iOriginal = Image.Load(imageStream))
{
imageStream.Position = 0;
double ratio = Math.Sqrt(newNumberOfPixels / (double)(iOriginal.Width * iOriginal.Height));
resize(imageStream, iOriginal, (int)Math.Round(iOriginal.Width * ratio, 0), (int)Math.Round(iOriginal.Height * ratio, 0), saveToStream, jpegQuality);
}
}
private static void resize(Stream origSource, Image image, int newWidth, int newHeight, Stream saveTo, int jpegQuality)
{
image.Mutate(x => x.Resize(newWidth, newHeight));
transformImage(image); // NOTE: transform image AFTER resizing it!!!
var format = Image.DetectFormat(origSource);
if (format.Name.ToLower() == "jpeg")
{
var encoder = new JpegEncoder();
encoder.Quality = jpegQuality;
image.SaveAsJpeg(saveTo, encoder);
}
else
image.Save(saveTo, format);
}
private static void transformImage(Image image)
{
IExifValue exifOrientation = image.Metadata?.ExifProfile?.GetValue(ExifTag.Orientation);
if (exifOrientation == null)
return;
RotateMode rotateMode;
FlipMode flipMode;
setRotateFlipMode(exifOrientation, out rotateMode, out flipMode);
image.Mutate(x => x.RotateFlip(rotateMode, flipMode));
image.Metadata.ExifProfile.SetValue(ExifTag.Orientation, (ushort)1);
}
private static void setRotateFlipMode(IExifValue exifOrientation, out RotateMode rotateMode, out FlipMode flipMode)
{
var orientation = (ushort)exifOrientation.GetValue();
switch (orientation)
{
case 2:
rotateMode = RotateMode.None;
flipMode = FlipMode.Horizontal;
break;
case 3:
rotateMode = RotateMode.Rotate180;
flipMode = FlipMode.None;
break;
case 4:
rotateMode = RotateMode.Rotate180;
flipMode = FlipMode.Horizontal;
break;
case 5:
rotateMode = RotateMode.Rotate90;
flipMode = FlipMode.Horizontal;
break;
case 6:
rotateMode = RotateMode.Rotate90;
flipMode = FlipMode.None;
break;
case 7:
rotateMode = RotateMode.Rotate90;
flipMode = FlipMode.Vertical;
break;
case 8:
rotateMode = RotateMode.Rotate270;
flipMode = FlipMode.None;
break;
default:
rotateMode = RotateMode.None;
flipMode = FlipMode.None;
break;
}
}
}
/* CREATE A SCATTER PLOT JPEG/PNG IMAGE */
public static class ScatterPlot
{
static readonly Rgba32 WHITE = new Rgba32(255, 255, 255);
static readonly Rgba32 BLACK = new Rgba32(0, 0, 0);
static readonly Rgba32 RED = new Rgba32(255, 0, 0);
static readonly Rgba32 BLUE = new Rgba32(0, 0, 255);
static readonly Rgba32 GREEN = new Rgba32(0, 192, 0);
static readonly Rgba32 PURPLE = new Rgba32(128, 0, 128);
static readonly Rgba32 ORANGE = new Rgba32(255, 164, 0);
static readonly Rgba32 YELLOW = new Rgba32(255, 225, 0);
static readonly Rgba32 MAGENTA = new Rgba32(255, 0, 255);
static readonly Rgba32 AQUA = new Rgba32(0, 225, 255);
static readonly Rgba32 BLUEJEAN = new Rgba32(0, 128, 255);
static readonly Rgba32 BROWN = new Rgba32(150, 75, 50);
static readonly Rgba32 CHARTREUSE = new Rgba32(223, 255, 0);
static readonly Rgba32 DODGERBLUE = new Rgba32(30, 144, 255);
static readonly Rgba32 NAVY = new Rgba32(0, 0, 128);
static readonly Rgba32 DARKRED = new Rgba32(139, 0, 0);
static readonly Rgba32[] colors = new Rgba32[] { WHITE, BLACK, RED, BLUE, GREEN, PURPLE, ORANGE, YELLOW, MAGENTA, AQUA, BLUEJEAN, BROWN, DODGERBLUE, CHARTREUSE, NAVY, DARKRED };
public static void CreateJPEG(Stream stream, ScatterPlotColors backgroundColor, IEnumerable<PlotPoint> points, int width, int height, int pointSize, int jpegQuality = 100)
{
using (var bmp = new Image<Rgba32>(width / pointSize + 6, height / pointSize + 6, colors[(int)backgroundColor]))
create(stream, width, height, bmp, points, pointSize, new JpegEncoder() { Quality = jpegQuality });
}
public static void CreateJPEG(string filename, ScatterPlotColors backgroundColor, IEnumerable<PlotPoint> points, int width, int height, int pointSize, int jpegQuality = 100)
{
using (var stream = File.Create(filename))
CreateJPEG(stream, backgroundColor, points, width, height, pointSize, jpegQuality);
}
public static void CreatePNG(Stream stream, IEnumerable<PlotPoint> points, int width, int height, int pointSize)
{
using (var bmp = new Image<Rgba32>(width / pointSize + 6, height / pointSize + 6))
create(stream, width, height, bmp, points, pointSize, new PngEncoder());
}
public static void CreatePNG(string filename, IEnumerable<PlotPoint> points, int width, int height, int pointSize)
{
using (var stream = File.Create(filename))
CreatePNG(stream, points, width, height, pointSize);
}
private static double normalize(float min, float max, float value)
{
double x = max - min;
if(x == 0)
return 0;
return (value - min) / x;
}
private static void create(Stream stream, int width, int height, Image<Rgba32> bmp, IEnumerable<PlotPoint> points, int pointSize, SixLabors.ImageSharp.Formats.IImageEncoder imageEncoder)
{
float xMax = float.MinValue, xMin = float.MaxValue, yMax = float.MinValue, yMin = float.MaxValue;
foreach (var pt in points)
{
xMax = Math.Max(pt.x, xMax);
xMin = Math.Min(pt.x, xMin);
yMax = Math.Max(pt.y, yMax);
yMin = Math.Min(pt.y, yMin);
}
float xDelta = Math.Max(1, xMax - xMin), yDelta = Math.Max(1, yMax - yMin);
int w = width / pointSize;
int h = height / pointSize;
foreach (var pt in points)
{
int x = (int)(w * normalize(xMin, xMax, pt.x));
int y = (int)(h * normalize(yMin, yMax, pt.y));
bmp[x + 3, y + 3] = colors[((int)pt.color) % colors.Length];
}
bmp.Mutate(x => x.Flip(FlipMode.Vertical));
bmp.Mutate(x => x.Resize(width, height));
bmp.Save(stream, imageEncoder);
}
}
public class PlotPoint
{
public ScatterPlotColors color { get; }
public float x { get; }
public float y { get; }
public PlotPoint(float x, float y, ScatterPlotColors color)
{
this.x = x;
this.y = y;
this.color = color;
}
}
public enum ScatterPlotColors
{
WHITE,
BLACK,
RED,
BLUE,
GREEN,
PURPLE,
ORANGE,
YELLOW,
MAGENTA,
AQUA,
BLUEJEAN,
BROWN,
CHARTREUSE,
DODGERBLUE,
NAVY,
DARKRED
}
/* CREATE A PNG HISTOGRAM OF AN IMAGE */
public static class Histogram
{
/// <summary>
/// Create a histogram from the data in a stream
/// </summary>
public static MemoryStream CreatePNG(Stream stream, int width, int height, LRGB lrgb, byte alphaChannel = 128, bool clipBlackAndWhite = true, byte luminanceShade = 255)
{
using (var bmp = Image<Rgb24>.Load(stream))
{
return create(bmp, width, height, lrgb, alphaChannel, clipBlackAndWhite, luminanceShade);
}
}
/// <summary>
/// Create a histogram from the data in a file
/// </summary>
public static MemoryStream CreatePNG(string filename, int width, int height, LRGB lrgb, byte alphaChannel = 128, bool clipBlackAndWhite = true, byte luminanceShade = 255)
{
using (var bmp = Image<Rgb24>.Load(filename))
{
return create(bmp, width, height, lrgb, alphaChannel, clipBlackAndWhite, luminanceShade);
}
}
private static MemoryStream create(Image bmp, int width, int height, LRGB lrgb, byte alpha, bool clip, byte shade)
{
ulong[] lumin = new ulong[256];
ulong[] red = new ulong[256];
ulong[] green = new ulong[256];
ulong[] blue = new ulong[256];
var bred = (lrgb & LRGB.RED) != 0;
var bgreen = (lrgb & LRGB.GREEN) != 0;
var bblue = (lrgb & LRGB.BLUE) != 0;
var blumin = (lrgb == LRGB.LUMINANCE);
int w = bmp.Width;
int h = bmp.Height;
var bmp2 = bmp.CloneAs<Rgb24>();
for (int y = 0; y < h; y++)
{
Span<Rgb24> pixelRow = bmp2.GetPixelRowSpan(y);
for (int x = 0; x < w; x++)
{
var c = pixelRow[x];
lumin[(int)Math.Round((c.R + c.G + c.B) / 3.0)]++;
red[c.R]++;
green[c.G]++;
blue[c.B]++;
}
}
ulong max = 0;
int a = (clip ? 1 : 0), b = (clip ? 255 : 256);
for (int i = a; i < b; i++)
{
if (!blumin)
{
if (bred)
if (max < red[i])
max = red[i];
if (bgreen)
if (max < green[i])
max = green[i];
if (bblue)
if (max < blue[i])
max = blue[i];
}
else if (max < lumin[i])
max = lumin[i];
}
double HEIGHTFACTOR = 256.0 / max;
if (blumin)
{
using (var bmplum = new Image<Rgba32>(256, 256))
{
var penlum = new VerticalPen(new Rgba32(shade, shade, shade, alpha));
for (int i = 0; i < 256; i++)
penlum.Draw(bmplum, i, (int)(lumin[i] * HEIGHTFACTOR));
bmplum.Mutate(x => x.Resize(width, height));
MemoryStream ms = new MemoryStream();
bmplum.Save(ms, new PngEncoder());
return ms;
}
}
else
{
using (var bmppre = new Image<Rgba32>(256, 256))
{
Image<Rgba32>? bmpred = null, bmpgreen = null, bmpblue = null;
VerticalPen? penred = null, pengreen = null, penblue = null;
if (bred)
{
bmpred = new Image<Rgba32>(256, 256);
penred = new VerticalPen(new Rgba32(255, 0, 0, alpha));
}
if (bgreen)
{
bmpgreen = new Image<Rgba32>(256, 256);
pengreen = new VerticalPen(new Rgba32(0, 255, 0, alpha));
}
if (bblue)
{
bmpblue = new Image<Rgba32>(256, 256);
penblue = new VerticalPen(new Rgba32(0, 0, 255, alpha));
}
for (int i = 0; i < 256; i++)
{
if (bred)
penred.Draw(bmpred, i, (int)(red[i] * HEIGHTFACTOR));
if (bgreen)
pengreen.Draw(bmpgreen, i, (int)(green[i] * HEIGHTFACTOR));
if (bblue)
penblue.Draw(bmpblue, i, (int)(blue[i] * HEIGHTFACTOR));
}
if (bred)
{
bmppre.Mutate(x => x.DrawImage(bmpred, 1));
bmpred.Dispose();
}
if (bgreen)
{
bmppre.Mutate(x => x.DrawImage(bmpgreen, 1));
bmpgreen.Dispose();
}
if (bblue)
{
bmppre.Mutate(x => x.DrawImage(bmpblue, 1));
bmpblue.Dispose();
}
bmppre.Mutate(x => x.Resize(width, height));
MemoryStream ms = new MemoryStream();
bmppre.Save(ms, new PngEncoder());
return ms;
}
}
}
internal class VerticalPen
{
private readonly Rgba32 color;
public VerticalPen(Rgba32 color)
{
this.color = color;
}
public void Draw(Image<Rgba32> bmp, int row, int height)
{
if (height <= bmp.Height)
for (int y = height - 1; y >= 0; y--)
bmp[row, bmp.Height - 1 - y] = color;
}
}
public enum LRGB
{
LUMINANCE = 0,
RED = 1,
GREEN = 2,
BLUE = 4,
REDBLUE = 1 | 4,
REDGREEN = 1 | 2,
BLUEGREEN = 2 | 4,
REDGREENBLUE = 1 | 2 | 4
}
}
}
示例用法
另请参阅:控制台应用程序示例
这是MVC Web 应用程序中的视图。
@{
ViewData["Title"] = "/Home/UploadImages";
}
<div class="text-center">
<h1 class="display-4">UploadImages</h1>
<form enctype="multipart/form-data" method="post">
<div>
<input type="file" name="images" accept="image/jpeg, image/gif, image/png" multiple />
</div>
<div>
<button type="submit" class="btn btn-primary">UPLOAD</button>
</div>
</form>
@if(Model is int)
{
<p>@Model images saved.</p>
}
</div>
现在介绍控制器代码:
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.TagHelpers;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult UploadImages()
{
return View();
}
[HttpPost]
[DisableRequestSizeLimit] // NOTE: NOT RECOMMENDED - SET A LIMIT
public IActionResult UploadImages(IFormCollection form)
{
int count = 0;
foreach(var image in form.Files)
{
if(image.ContentType.StartsWith("image/"))
{
using (var openfs = image.OpenReadStream())
{
string filename = "thumbnail-" + image.FileName;
if (System.IO.File.Exists(filename))
System.IO.File.Delete(filename);
using (var savefs = System.IO.File.OpenWrite(filename))
{
// NOTE: RESIZE IMAGE TO 10K PIXEL THUMBNAIL; THIS WILL ALSO FLIP AND ROTATE IMAGE AS NEEDED
ImageUtil.Resize.SaveImage(openfs, 10000, savefs);
count++;
}
}
}
}
return View(count);
}
public IActionResult Index()
{
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
如果您喜欢此文章,请收藏、点赞、评论,谢谢,祝您快乐每一天。
相关文章:

ASP.NET Core SixLabors.ImageSharp v1.0 的图像实用程序类 web示例
这个小型实用程序库需要将 NuGet SixLabors.ImageSharp包(版本 1.0.4)添加到.NET Core 3.1/ .NET 6 / .NET 8项目中。它与Windows、Linux和 MacOS兼容。 这已针对 ImageSharp v3.0.1 进行了重新设计。 它可以根据百万像素数或长度乘以宽度来调整图像大…...
ffmpeg configure 研究1-命令行参数的分析
author: hjjdebug date: 2025年 02月 14日 星期五 17:16:12 CST description: ffmpeg configure 研究1 ./configure 命令行参数的分析 文章目录 1 configure 对命令行参数的分析,在4019行1.1 函数名称: is_in1.2. 函数名称: enable1.3. 函数名称: set_all 2 执行退出判断的关键…...

数据结构与算法之排序算法-归并排序
排序算法是数据结构与算法中最基本的算法之一,其作用就是将一些可以比较大小的数据进行有规律的排序,而想要实现这种排序就拥有很多种方法~ 那么我将通过几篇文章,将排序算法中各种算法细化的,详尽的为大家呈现出来: …...

高血压危险因素分析(项目分享)
高血压危险因素分析(项目分享) 高血压作为一种极为常见的慢性疾病,正严重威胁着大众健康。它的发病机制较为复杂,涉及多个方面的因素。 在一份临床采集的数据的基础上,我们通过数据分析手段深入观察一下 BMI…...

java集合框架之Map系列
前言 首先从最常用的HashMap开始。HashMap是基于哈希表实现的,使用数组和链表(或红黑树)的结构。在Java 8之后,当链表长度超过阈值时会转换为红黑树,以提高查询效率。哈希冲突通过链地址法解决。需要明确的是ÿ…...
android设置添加设备QR码信息
摘要:客户衍生需求,通过扫QR码快速获取设备基础信息,并且基于POS SDK进行打印。 1. 定位至device info的xml添加相关perference Index: vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/my_device_info.xml--- vendor/medi…...

Python实现微博关键词爬虫
1.背景介绍 随着社交媒体的广泛应用,微博上的海量数据成为了很多研究和分析的重要信息源。为了方便获取微博的相关内容,本文将介绍如何使用Python编写一个简单的爬虫脚本,从微博中抓取指定关键词的相关数据,并将这些数据保存为Ex…...
linux概念详解
用户守护进程 用户空间守护进程是一些在后台运行的长期服务程序,提供系统级服务。 下面举一些例子。 网络服务: 如sshd(SSH服务)、httpd(HTTP服务)。 sshd:sshd 守护进程会在后台运行&#x…...

【设计模式】-工厂模式(简单工厂、工厂方法、抽象工厂)
工厂模式(简单工厂、工厂方法、抽象工厂) 介绍 简单工厂模式 简单工厂模式不属于23种GoF设计模式之一,但它是一种常见的设计模式。它提供了一种创建对象的接口,但由子类决定要实例化的类是哪一个。这样,工厂方法模式让类的实例化推迟到子类…...

AMESim中批处理功能的应用
AMESim 软件的批处理功能是一项能显著提高仿真效率和灵活性的功能,以下是其介绍与应用说明: 一 功能介绍 参数扫描功能:用户可以指定模型中一个或多个参数的取值范围和步长,批处理功能会自动遍历这些参数组合,进行多…...

《Spring实战》(第6版)第1章 Spring起步
第1部分 Spring基础 第1章 Spring起步 1.1 什么是Spring Spring的核心是提供一个容器(container)。 称为Spring应用上下文(Spring application context)。 创建和管理应用的组件(bean),与上下文装配在一起。 Bean装配通过依赖注入(Dependency Injection,DI)。…...
E卷-特殊的加密算法-(200分)
专栏订阅🔗 特殊的加密算法 问题描述 有一种特殊的加密算法,明文为一段数字串,经过密码本查找转换,生成另一段密文数字串。规则如下: 明文为一段由 0-9 组成的数字串。密码本为由数字 0-9 组成的二维数组。需要按明文串的数字顺序在密码本里找到同样的数字串,密码本里…...

QT 异步编程之多线程
一、概述 1、在进行桌面应用程序开发的时候,假设应用程序在某些情况下需要处理比较复制的逻辑,如果只有一个线程去处理,就会导致窗口卡顿,无法处理用户的相关操作。这种情况下就需要使用多线程,其中一个线程处理窗口事…...
K-均值(K-means)
K-均值(K-means)是一种常用的无监督学习算法,用于将数据集中的样本分成 K 个簇。该算法的过程大致如下: 1. 随机初始化 K 个聚类中心(centroid)。 2. 将每个样本分配到与其最近的聚类中心所代表的簇。 3. …...
AI agent 未来好的趋势:AI医疗影像、智能客服、个性化推荐
AI agent 未来好的趋势:AI医疗影像、智能客服、个性化推荐 目录 AI agent 未来好的趋势:AI医疗影像、智能客服、个性化推荐比特币AI Agents稳定币扩容区块链AI基础设施AI驱动的软件应用AI赋能的行业应用AI医疗影像、智能客服、个性化推荐AI药物研发比特币 市场与机构化:2024…...

接入 SSL 认证配置:满足等保最佳实践
前言 随着信息安全形势的日益严峻,等保(信息安全等级保护)要求成为各行业信息系统必须遵守的标准。在数据库领域,OpenGauss作为一款高性能、安全、可靠的开源关系型数据库,也需要满足等保要求,确保数据的安…...

微软AutoGen高级功能——Selector Group Chat
介绍 大家好,这次给大家分享的内容是微软AutoGen框架的高级功能Selector Group Chat(选择器群聊),"选择器群聊"我在给大家分享的这篇博文的代码中有所体现微软AutoGen介绍——Custom Agents创建自己的Agents-CSDN博客,但是并没有详…...

w206基于Spring Boot的农商对接系统的设计与实现
🙊作者简介:多年一线开发工作经验,原创团队,分享技术代码帮助学生学习,独立完成自己的网站项目。 代码可以查看文章末尾⬇️联系方式获取,记得注明来意哦~🌹赠送计算机毕业设计600个选题excel文…...

Springboot中使用Elasticsearch(部署+使用+讲解 最完整)
目录 引言 一、docker中安装Elasticsearch 1、创建es专有的网络 2、开放端口 3、在es-net网络上安装es和kibana 4、可能出现的问题 5、测试 6、安装IK分词器 7、测试IK分词器 二、结合业务实战 1、准备依赖 2、配置yml 3、读取yml配置 4、准备es配置类 5、编写测…...

深度求索—DeepSeek API的简单调用(Java)
DeepSeek简介 DeepSeek(深度求索)是由中国人工智能公司深度求索(DeepSeek Inc.)研发的大规模语言模型(LLM),专注于提供高效、智能的自然语言处理能力,支持多种场景下的文本生成、对…...
内存分配函数malloc kmalloc vmalloc
内存分配函数malloc kmalloc vmalloc malloc实现步骤: 1)请求大小调整:首先,malloc 需要调整用户请求的大小,以适应内部数据结构(例如,可能需要存储额外的元数据)。通常,这包括对齐调整,确保分配的内存地址满足特定硬件要求(如对齐到8字节或16字节边界)。 2)空闲…...
synchronized 学习
学习源: https://www.bilibili.com/video/BV1aJ411V763?spm_id_from333.788.videopod.episodes&vd_source32e1c41a9370911ab06d12fbc36c4ebc 1.应用场景 不超卖,也要考虑性能问题(场景) 2.常见面试问题: sync出…...
生成 Git SSH 证书
🔑 1. 生成 SSH 密钥对 在终端(Windows 使用 Git Bash,Mac/Linux 使用 Terminal)执行命令: ssh-keygen -t rsa -b 4096 -C "your_emailexample.com" 参数说明: -t rsa&#x…...
反射获取方法和属性
Java反射获取方法 在Java中,反射(Reflection)是一种强大的机制,允许程序在运行时访问和操作类的内部属性和方法。通过反射,可以动态地创建对象、调用方法、改变属性值,这在很多Java框架中如Spring和Hiberna…...

微服务商城-商品微服务
数据表 CREATE TABLE product (id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 商品id,cateid smallint(6) UNSIGNED NOT NULL DEFAULT 0 COMMENT 类别Id,name varchar(100) NOT NULL DEFAULT COMMENT 商品名称,subtitle varchar(200) NOT NULL DEFAULT COMMENT 商…...
WEB3全栈开发——面试专业技能点P2智能合约开发(Solidity)
一、Solidity合约开发 下面是 Solidity 合约开发 的概念、代码示例及讲解,适合用作学习或写简历项目背景说明。 🧠 一、概念简介:Solidity 合约开发 Solidity 是一种专门为 以太坊(Ethereum)平台编写智能合约的高级编…...
CRMEB 框架中 PHP 上传扩展开发:涵盖本地上传及阿里云 OSS、腾讯云 COS、七牛云
目前已有本地上传、阿里云OSS上传、腾讯云COS上传、七牛云上传扩展 扩展入口文件 文件目录 crmeb\services\upload\Upload.php namespace crmeb\services\upload;use crmeb\basic\BaseManager; use think\facade\Config;/*** Class Upload* package crmeb\services\upload* …...

python执行测试用例,allure报乱码且未成功生成报告
allure执行测试用例时显示乱码:‘allure’ �����ڲ����ⲿ���Ҳ���ǿ�&am…...
CSS设置元素的宽度根据其内容自动调整
width: fit-content 是 CSS 中的一个属性值,用于设置元素的宽度根据其内容自动调整,确保宽度刚好容纳内容而不会超出。 效果对比 默认情况(width: auto): 块级元素(如 <div>)会占满父容器…...
音视频——I2S 协议详解
I2S 协议详解 I2S (Inter-IC Sound) 协议是一种串行总线协议,专门用于在数字音频设备之间传输数字音频数据。它由飞利浦(Philips)公司开发,以其简单、高效和广泛的兼容性而闻名。 1. 信号线 I2S 协议通常使用三根或四根信号线&a…...