feat: update
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
package com.schisandra.auth.application.controller;
|
||||
|
||||
import com.schisandra.auth.common.utils.RotateImageUtils;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
/**
|
||||
* @Classname Test
|
||||
* @BelongsProject: schisandra-cloud-storage
|
||||
* @BelongsPackage: com.schisandra.auth.application.controller
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-06-06 12:07
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class Test {
|
||||
public static void main(String[] args){
|
||||
InputStream inputStream = ReactRotateCaptchaController.class.getClassLoader().getResourceAsStream("image/13000.png");
|
||||
SecureRandom random = new SecureRandom();
|
||||
double randomNumber = random.nextInt(280) + 40;
|
||||
BufferedImage bufferedImage = null;
|
||||
try {
|
||||
bufferedImage = Thumbnails.of(inputStream).size(1280,1024).rotate(randomNumber).asBufferedImage();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
BufferedImage newCompleteImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(),
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
newCompleteImage.createGraphics().drawImage(bufferedImage, 0, 0, null);
|
||||
String img = null;
|
||||
try {
|
||||
img = RotateImageUtils.BufferedImageToBase64(newCompleteImage);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
System.out.println(img);
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user