生成随机图片

java 复制代码
package com.zhuguohui.app.lib.tools;

/**
 * Created by zhuguohui
 * Date: 2024/6/1
 * Time: 13:39
 * Desc:获取随机图片
 */
public class RandomImage {

//    static final String url= "https://picsum.photos/%d/%d?random=%d";
    static final String url= "https://source.unsplash.com/%dx%d/?beauty&random=%d";


    public static String get(int width,int height){
        return String.format(url,width,height,(int)(Math.random()*100));
    }
}

上面的代码可以生成随机图片。而且内容可以指定 **"https://source.unsplash.com/%dx%d/?beauty\&random=%d"**比如?后面的beauty返回的就是美女图片

效果

相关推荐
Java牛马1 小时前
SpringBoot Starter 依赖相关总结
java·spring·springboot·starter·自动装配·依赖
丰锋ff2 小时前
基于 Qt 的智能门禁系统(二)
开发语言·qt
吴声子夜歌2 小时前
Java面试——Spring Cloud原理及应用(二)
java·spring cloud·面试
fpcc2 小时前
跟我学C++中级篇——编译期的条件选择
开发语言·c++
SomeB1oody2 小时前
【RustyML入门】6.3. 并行归约
开发语言·后端·机器学习·rust·教程
东小西2 小时前
【SAA实战】第 1 篇:ReactAgent 入门——先撸个"会调工具的助手"跑起来
java·人工智能·spring
mqiqe3 小时前
AgentScope Java 2.0 协议集成全景解析:A2A、AG-UI、Agent Protocol 三大开放协议实战指南
java·开发语言·ui
lzhdim3 小时前
12、JavaScript常见的内存泄露问题 - JavaScript学习系列文章
开发语言·前端·javascript·学习·ecmascript
脉动数据行情3 小时前
Java 实现台股 TWSE/TPEx 行情采集(个股 + K 线)
java·开发语言·twse·tpex·台股
爱学习的小邓同学3 小时前
Golang --- (1)第一个Golang程序
开发语言·后端·golang