From 2800fa4f32f3900509cb4d6eefaf2bfaf54efdd7 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 21 Apr 2025 18:29:09 +0800
Subject: [PATCH] fix: 天气显示
---
src/utils/cesium/compressImage2.js | 60 ++++++++++++++++++++++++++++++------------------------------
1 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/src/utils/cesium/compressImage2.js b/src/utils/cesium/compressImage2.js
index 0fa39fc..e28a427 100644
--- a/src/utils/cesium/compressImage2.js
+++ b/src/utils/cesium/compressImage2.js
@@ -8,39 +8,39 @@
* Copyright (c) 2024 by GuLiMmo, All Rights Reserved.
*/
export default function compressImage(
- src,
- maxWidth,
- maxHeight,
- outputFormat = 'image/jpeg',
- quality = 0.7,
+ src,
+ maxWidth,
+ maxHeight,
+ outputFormat = 'image/jpeg',
+ quality = 0.7
) {
- return new Promise((resolve, reject) => {
- const image = new Image();
- image.setAttribute('crossOrigin', 'Anonymous');
- image.src = src;
- image.onload = () => {
- let width = image.width;
- let height = image.height;
+ return new Promise((resolve, reject) => {
+ const image = new Image()
+ image.setAttribute('crossOrigin', 'Anonymous')
+ image.src = src
+ image.onload = () => {
+ let width = image.width
+ let height = image.height
- if (width > maxWidth) {
- height *= maxWidth / width;
- width = maxWidth;
- }
+ if (width > maxWidth) {
+ height *= maxWidth / width
+ width = maxWidth
+ }
- if (height > maxHeight) {
- width *= maxHeight / height;
- height = maxHeight;
- }
+ if (height > maxHeight) {
+ width *= maxHeight / height
+ height = maxHeight
+ }
- const canvas = document.createElement('canvas');
- canvas.width = width;
- canvas.height = height;
- const ctx = canvas.getContext('2d');
- ctx.drawImage(image, 0, 0, width, height);
+ const canvas = document.createElement('canvas')
+ canvas.width = width
+ canvas.height = height
+ const ctx = canvas.getContext('2d')
+ ctx.drawImage(image, 0, 0, width, height)
- const newDataUrl = canvas.toDataURL(outputFormat, quality);
- resolve(newDataUrl);
- };
- image.onerror = reject;
- });
+ const newDataUrl = canvas.toDataURL(outputFormat, quality)
+ resolve(newDataUrl)
+ }
+ image.onerror = reject
+ })
}
--
Gitblit v1.9.3