From e14fd2f9e2250a172ec81f8e6ec213a09f522c9d Mon Sep 17 00:00:00 2001 From: Dark_Phoenix_ <92178883+0DarkPhoenix@users.noreply.github.com> Date: Sun, 8 Jun 2025 11:02:12 +0200 Subject: [PATCH] Improve image resizer features (#90) * Improved performance on the Unicode Search page: - Created new flexSearch component (Faster than fuzzySearch). For more information, see https://github.com/nextapps-de/flexsearch - Replaced fuzzySearch with the flexSearch component on the unicode search page - Fixed a bug where the search limit counter didn't have any effect - Reduced the default search limit from 100 to 40 to reduce lag from loading all the ui elements * Added clarification to comment * components.d.ts update * - Replaced FuzzySearch with FlexSearch on the ISO 3166 Searcher page - Reduced the debounce from 500ms to 250ms - Reduced the default search limit from 100 to 20, and fixed a bug where the search limit wasn't applied when the value changed - Added the `readonly` prop to the `input-copyable` field - Added the `readonly` flag to all input copyable fields on the unicode search and iso 3166 searcher pages * Merged new changes to flexSearch * chore: vercel optimisation tentative * - Added controls to lock the aspect ratio, set preset aspect ratios or set a custom aspect ratio - Added a reset button to fill the width and height with the dimensions of the original image - Added validation and warnings to prevent the width or height value to be lower than 1 or higher than the values HTML Canvas supports (32767, or more than 268 million pixels of area) - Added logic to not display the preview image when one of the dimensions is higher than 7680 pixels due to performance reasons - Fixed an issue with the download options where you never got the selected image type when clicking a download option, and instead always getting a .png. - Changed the download options to the file type options supported by HTML Canvas * Fixed an issue with width and height input for locked aspect ratio --------- Co-authored-by: ShareVB --- components.d.ts | 7 + locales/en.yml | 4 +- locales/ru.yml | 2 +- locales/uk.yml | 2 +- src/tools/image-resizer/image-resizer.vue | 694 ++++++++++++++++++++-- src/tools/image-resizer/index.ts | 2 +- 6 files changed, 648 insertions(+), 63 deletions(-) diff --git a/components.d.ts b/components.d.ts index d1320009..dde3e1ba 100644 --- a/components.d.ts +++ b/components.d.ts @@ -328,6 +328,13 @@ declare module '@vue/runtime-core' { NLayout: typeof import('naive-ui')['NLayout'] NLayoutSider: typeof import('naive-ui')['NLayoutSider'] NMenu: typeof import('naive-ui')['NMenu'] + NRadio: typeof import('naive-ui')['NRadio'] + NRadioGroup: typeof import('naive-ui')['NRadioGroup'] + NScrollbar: typeof import('naive-ui')['NScrollbar'] + NSelect: typeof import('naive-ui')['NSelect'] + NSlider: typeof import('naive-ui')['NSlider'] + NSpin: typeof import('naive-ui')['NSpin'] + NTooltip: typeof import('naive-ui')['NTooltip'] NP: typeof import('naive-ui')['NP'] NRadio: typeof import('naive-ui')['NRadio'] NRadioGroup: typeof import('naive-ui')['NRadioGroup'] diff --git a/locales/en.yml b/locales/en.yml index 3eb21c58..eb2465a5 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -448,7 +448,7 @@ tools: image-resizer: title: Image resizer - description: Convert the width and height of an image file, preview, and download it in a desired format (.jpg, .jpeg, .png, .bmp, .ico, .svg) + description: Convert the width and height of an image file, preview, and download it in a desired format json-to-object: title: JSON to object @@ -471,7 +471,7 @@ tools: message: SIP message message-tips: Paste your SIP message here... result: Result - sucess: Sucess + sucess: Success failure: Failure uuid-converter: diff --git a/locales/ru.yml b/locales/ru.yml index c9f8aed7..da0e371e 100644 --- a/locales/ru.yml +++ b/locales/ru.yml @@ -443,7 +443,7 @@ tools: image-resizer: title: Изменение размера изображения - description: Изменяйте ширину и высоту изображения, предварительно просматривайте и загружайте его в нужном формате (.jpg, .jpeg, .png, .bmp, .ico, .svg). + description: Изменяйте ширину и высоту изображения, предварительно просматривайте и загружайте его в нужном формате. multi-link-downloader: title: Множественный загрузчик ссылок diff --git a/locales/uk.yml b/locales/uk.yml index e1574c78..9a891d0d 100644 --- a/locales/uk.yml +++ b/locales/uk.yml @@ -446,7 +446,7 @@ tools: image-resizer: title: Зміна розміру зображення - description: Змініть ширину та висоту файлу зображення, перегляньте та завантажте його у бажаному форматі (.jpg, .jpeg, .png, .bmp, .ico, .svg). + description: Змініть ширину та висоту файлу зображення, перегляньте та завантажте його у бажаному форматі. json-to-object: title: JSON в об'єкт diff --git a/src/tools/image-resizer/image-resizer.vue b/src/tools/image-resizer/image-resizer.vue index 3c88ff1b..aca4824c 100644 --- a/src/tools/image-resizer/image-resizer.vue +++ b/src/tools/image-resizer/image-resizer.vue @@ -1,24 +1,259 @@ @@ -105,66 +424,318 @@ function downloadImage(format: string) {
- + -
-

Original Image Dimensions: {{ originalImageWidth }}x{{ originalImageHeight }}px

+
+

+ Original Image Dimensions: {{ originalImageWidth }}x{{ originalImageHeight }}px +

+ + + Reset width and height to image dimensions +
- -
- - + +
+ +
+

Dimensions

+
+ + +
+
+ + +
+ + +
+

+ ⚠️ Width and height must be greater than 0 +

+
+
+

+ ⚠️ Canvas size exceeds browser limits (max: {{ MAX_CANVAS_DIMENSION.toLocaleString() }}px per side, max area: {{ Math.floor(MAX_CANVAS_AREA / 1000000) }}M pixels) +

+
+
+ + +
+

Aspect Ratio

+ + +
+ {{ displayedAspectRatio }} +
+ + +
+ +
+
+ + +
+

Aspect Ratio Presets

+ + +
+ + + Apply + +
+ + +
+
+ + : + +
+
+
-
- - -
-
+ +
+ +
+ +

Preview: {{ imageWidth }}x{{ imageHeight }}px

+
- -
-
- -
-

Preview: {{ imageWidth }}x{{ imageHeight }}px

+ +
+

+ ⚠️ Preview not shown - dimensions too large ({{ imageWidth }}x{{ imageHeight }}px) +
+ Preview is disabled when width or height exceeds 7,680 pixels for performance reasons. +

+
- -

Download Options:

-
- - Download JPG - - - Download PNG - - - Download BMP - - - Download SVG - - - Download ICO - + +
+

Download Options:

+
+ + Download JPG + + + Download PNG + + + Download WebP + +
+