diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4604c7d..d0d65b5 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,17 +4,12 @@
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -64,7 +59,7 @@
"Vitest.mergeText.executor": "Run",
"Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor": "Run",
"Vitest.mergeText.should merge lines, preserve blank lines and trailing spaces when both deleteBlankLines and deleteTrailingSpaces are false.executor": "Run",
- "git-widget-placeholder": "main",
+ "git-widget-placeholder": "4-convert-jpg-to-png",
"ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/Users/HP/IdeaProjects/omni-tools/src/assets",
@@ -79,6 +74,7 @@
"npm.script:create:tool.executor": "Run",
"npm.test.executor": "Run",
"npm.test:e2e.executor": "Run",
+ "npm.test:e2e:run.executor": "Run",
"prettierjs.PrettierConfiguration.Package": "C:\\Users\\HP\\IdeaProjects\\omni-tools\\node_modules\\prettier",
"project.structure.last.edited": "Problems",
"project.structure.proportion": "0.0",
@@ -112,20 +108,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -166,13 +149,23 @@
+
+
+
+
+
+
+
+
+
+
+
-
@@ -208,14 +201,8 @@
-
-
-
- 1719102365836
-
-
-
- 1719102365836
+
+
@@ -601,7 +588,15 @@
1719519913328
-
+
+
+ 1719521563441
+
+
+
+ 1719521563441
+
+
@@ -634,7 +629,6 @@
-
@@ -659,7 +653,8 @@
-
+
+
diff --git a/src/pages/image/png/change-colors-in-png/change-colors-in-png.e2e.spec.ts b/src/pages/image/png/change-colors-in-png/change-colors-in-png.e2e.spec.ts
index 83eda93..38fa772 100644
--- a/src/pages/image/png/change-colors-in-png/change-colors-in-png.e2e.spec.ts
+++ b/src/pages/image/png/change-colors-in-png/change-colors-in-png.e2e.spec.ts
@@ -2,6 +2,7 @@ import { expect, test } from '@playwright/test';
import { Buffer } from 'buffer';
import path from 'path';
import Jimp from 'jimp';
+import { convertHexToRGBA } from '../../../../utils/color';
test.describe('Change colors in png', () => {
test.beforeEach(async ({ page }) => {
@@ -15,7 +16,8 @@ test.describe('Change colors in png', () => {
await fileInput?.setInputFiles(imagePath);
await page.getByTestId('from-color-input').fill('#FF0000');
- await page.getByTestId('to-color-input').fill('#0000FF');
+ const toColor = '#0000FF';
+ await page.getByTestId('to-color-input').fill(toColor);
// Click on download
const downloadPromise = page.waitForEvent('download');
@@ -36,6 +38,6 @@ test.describe('Change colors in png', () => {
// Check that the first pixel is transparent
const image = await Jimp.read(fileContent);
const color = image.getPixelColor(0, 0);
- expect(color).toBe(0x0000ffff);
+ expect(color).toBe(convertHexToRGBA(toColor));
});
});
diff --git a/src/utils/color.ts b/src/utils/color.ts
index 8b45952..692a78e 100644
--- a/src/utils/color.ts
+++ b/src/utils/color.ts
@@ -20,3 +20,15 @@ export function areColorsSimilar(
return colorDistance(color1, color2) <= similarityThreshold;
}
+
+export function convertHexToRGBA(color: string): number {
+ // Remove the leading '#' if present
+ if (color.startsWith('#')) {
+ color = color.slice(1);
+ }
+
+ // Convert the color to a number and add the alpha channel
+ const colorValue = parseInt(color, 16);
+ const alphaChannel = 0xff;
+ return (colorValue << 8) | alphaChannel;
+}