?? ??:
2MB?? ? ??? ?? ???? ??? ???? ?? 2MB ???? ???? ???.
(?? ????: java ?? ????)
??? ??:
<dependency> <groupId>net.coobird</groupId> <artifactId>thumbnailator</artifactId> <version>0.4.8</version> </dependency>
?? ??? ???:
@Builder @NoArgsConstructor @AllArgsConstructor @Data public class FileCO { /** * 附件字節(jié)流 */ private byte[] fileContent; /** * 附件OID */ private UUID attachmentOid; }
(?? ??? ????: java ??? ????)
??? ??? ???:
@Builder @NoArgsConstructor @AllArgsConstructor @Data public class ImageInfo { /** * 圖片字節(jié)流 */ private byte[] imageBytes; /** * 圖片是否進(jìn)行壓縮 */ private Boolean compressFlag; /** * 圖片寬度 */ private Integer width; /** * 圖片高度 */ private Integer height; }
??? ?? ??:
@Slf4j public class ImageUtils { /** * 合法圖片大小為2MB */ private static final Long LEGAL_IMAGE_SIZE = 1024 * 2L; /** * 圖片壓縮 當(dāng)圖片大小大于2MB進(jìn)行等比例壓縮 * 不修改圖片尺寸進(jìn)行壓縮 * * @param fileCO * @return */ public static ImageInfo compressImageForScale(FileCO fileCO) throws IOException { byte[] imageBytes = fileCO.getFileContent(); UUID attachmentOid = fileCO.getAttachmentOid(); try { BufferedImage sourceImage = ImageIO.read(new ByteArrayInputStream(imageBytes)); //高度 int height = sourceImage.getHeight(); //寬度 int width = sourceImage.getWidth(); if (imageBytes.length <= 0 || imageBytes.length < LEGAL_IMAGE_SIZE * 1024) { return ImageInfo.builder() .imageBytes(imageBytes) .width(width) .height(height) .compressFlag(false) .build(); } long srcSize = imageBytes.length; double accuracy = getAccuracy(srcSize / 1024); while (imageBytes.length > LEGAL_IMAGE_SIZE * 1024) { ByteArrayInputStream inputStream = new ByteArrayInputStream(imageBytes); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(imageBytes.length); Thumbnails.of(inputStream) .scale(1f) .outputQuality(accuracy) .toOutputStream(outputStream); imageBytes = outputStream.toByteArray(); } log.info("【圖片壓縮】附件OID={} | 圖片原大小={}kb | 壓縮后大小={}kb", attachmentOid, srcSize / 1024, imageBytes.length / 1024); return ImageInfo.builder() .imageBytes(imageBytes) .width(width) .height(height) .compressFlag(true) .build(); } catch (Exception e) { log.error("【圖片壓縮】msg=圖片壓縮失敗!", e); throw e; } } /** * 計(jì)算壓縮精度 * * @param size * @return */ private static double getAccuracy(long size) { double accuracy; //圖片大小小于4M,壓縮精度為0.44;否則精度為0.4 if (size <= 2048 * 2) { accuracy = 0.44; } else { accuracy = 0.4; } return accuracy; } }
? ??? Java? ?? ??? ??? ???? ?? ??? ???? ?????.? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

settings.json ??? ??? ?? ?? ?? ?? ?? ??? ??? VSCODE ??? ??? ???? ? ?????. 1. ??? ?? ?? : Windows? C : \ Users \\ AppData \ Roaming \ Code \ User \ Settings.json, MacOS IS /users//library/applicationsupport/code/user/settings.json, linux? /home//.config/code/user/settings.json; 2. Workspace ?? ?? : .vscode/settings project root ????

JDBC ????? ???? ????? ?? ?? ?? ??? ?? ?? ??? ?? ? ?? ??? ?? ?? ?? ??? ???????. 1. ????? ????? Conn.SetAutoCommit (False)?? ??????. 2. ??? ? ????? ?? ?? SQL ??? ?????. 3. ?? ??? ??? ?? Conn.commit ()?? ???? ??? ???? ???? ?? ??? ???? Conn.Rollback ()?? ??????. ???, ? ??? ???? ????, ??? ???? ????, ?? ??? ??? ?? ??? ??? ???? ? ???????. ?? ?? ?? ???? ????? ??? ???? ?? ?? ???? ???? ??? ????? ?? ??? ??? ? ?? ???? ?? ????.

??? (DI) ISADESIGNPATTORNWHEREWHEDROUDIVESTESTESTETESTERGROWCONSTRUCTOR, 2.SPRINGFRAMEWWERTHUSENONTATIONS? ??@autowiredWithjava ?? CONCUTTATIONS LIKERWITHCONSTRUCTOR, ORFIELDINGESS.2.SPRINGFRAMEWWERTHUSENNOTATIONS

?? ?? ? ?? ???? ???? ?? Java.Time ???? ???? ??????. 2. LocalDate, LocalDateTime ? LocalTime? ?? ?? ??? ??? ?????. 3. () ???? ???? ?? ??? ??? ????. 4. ???/???? ??? ???? ??? ????? ??? ??????. 5. ZonedDateTime ? Zoneid? ???? ???? ??????. 6. DateTimeFormatter? ?? ?? ? ?? ?? ?? ???; 7. ??? ?? ?? ?? ??? ????? ?? ??????. ?? Java? ?? ??? ???? ??? ??? ???? Java.Timeapi ??? ?? ??? ???????.

thejvmenablesjava? "WriteOnce, Runynywhere"??? ?? excodecodethroughfourmaincomponents : 1. theclassloadersubsystemloads, ??, ? intinitializes.classfilesusingbootsprap, extension, andapplicationclassloaders, ensuringsecureandlazyclasloa

chromecanopenlocalfiles likehtmlandpdfsbyusing "OpenFile"OrdraggingTheMintoTheBrowser; ensuretHeadDressStartSwithFile : ///; 2.SecurityRestrictionSblockajax, LocalStorage, andcross-folderaccessonfile : //; usealocalsertpython-mhtpython-mhtpython-mhtppy

Pre-FormancetArtUptimeMoryUsage, Quarkusandmicronautleadduetocompile-timeprocessingandgraalvsupport, withquarkusoftenperforminglightbetterine serverless sinarios.2.thyvelopecosyste,

NetworkPortSandfirewallsworkTogetToenableCommunication whileensuringsecurity.1.networkportSarevirtualendpointsnumbered0–65535, Withwell-nownports like80 (http), 443 (https), 22 (ssh) ? 25 (smtp) ?? (specservices
