app icon, and remove android debug via .dev flavor
- debug .dev flavor doesn't work well with RUST-BACKTRACE and webview devtools - tauri android run already install debug without dev server
No files matched your search
|
After Width: | Height: | Size: 2.0 MiB |
@@ -0,0 +1,75 @@
|
|||||||
|
import sharp from "sharp";
|
||||||
|
import { spawnSync } from "child_process";
|
||||||
|
|
||||||
|
async function resizeAndMakeWhiteTransparent(inputPath, outputPath) {
|
||||||
|
const whiteThreshold = 250; // treat >= as white
|
||||||
|
const img = sharp(inputPath).ensureAlpha();
|
||||||
|
|
||||||
|
// Get metadata to compute resize dimensions preserving aspect ratio
|
||||||
|
const meta = await img.metadata();
|
||||||
|
const origW = meta.width || 0;
|
||||||
|
const origH = meta.height || 0;
|
||||||
|
if (!origW || !origH) throw new Error("Unable to read image dimensions");
|
||||||
|
|
||||||
|
const targetW = Math.max(origW, origH);
|
||||||
|
const targetH = targetW;
|
||||||
|
|
||||||
|
// Resize and output raw RGBA buffer
|
||||||
|
const { data, info } = await img
|
||||||
|
.resize(targetW, targetH, { fit: "fill" })
|
||||||
|
.raw()
|
||||||
|
.toBuffer({ resolveWithObject: true });
|
||||||
|
|
||||||
|
const { width: w, height: h, channels } = info; // channels should be 4 (RGBA)
|
||||||
|
if (channels < 3) throw new Error("Unexpected channel count");
|
||||||
|
|
||||||
|
// Check if image already has any transparency
|
||||||
|
let hasTransparency = false;
|
||||||
|
for (let i = 0; i < data.length; i += channels) {
|
||||||
|
if (data[i + 3] < 255) {
|
||||||
|
hasTransparency = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasTransparency) {
|
||||||
|
// Modify alpha for near-white pixels
|
||||||
|
for (let i = 0; i < data.length; i += channels) {
|
||||||
|
const r = data[i];
|
||||||
|
const g = data[i + 1];
|
||||||
|
const b = data[i + 2];
|
||||||
|
const a = channels === 4 ? data[i + 3] : 255;
|
||||||
|
|
||||||
|
if (
|
||||||
|
a > 0 &&
|
||||||
|
r >= whiteThreshold &&
|
||||||
|
g >= whiteThreshold &&
|
||||||
|
b >= whiteThreshold
|
||||||
|
) {
|
||||||
|
if (channels === 4) data[i + 3] = 0;
|
||||||
|
else {
|
||||||
|
// expand to RGBA if input lacked alpha
|
||||||
|
// create a new buffer would be required; throw for simplicity
|
||||||
|
throw new Error(
|
||||||
|
"Input image missing alpha channel; ensure ensureAlpha() was applied.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recreate and save PNG
|
||||||
|
await sharp(data, { raw: { width: w, height: h, channels } })
|
||||||
|
.png({ compressionLevel: 9 })
|
||||||
|
.toFile(outputPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [, , input] = process.argv;
|
||||||
|
if (!input) {
|
||||||
|
throw new Error(`Input is required: input=${input}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example usage
|
||||||
|
resizeAndMakeWhiteTransparent(input, "app-icon.png")
|
||||||
|
.then(() => spawnSync("pnpm tauri icon", { shell: true, stdio: "inherit" }))
|
||||||
|
.catch((err) => console.error(err));
|
||||||
@@ -5,22 +5,22 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:desktop": "cross-env RUST_BACKTRACE=1 tauri dev",
|
"dev:desktop": "cross-env RUST_BACKTRACE=1 tauri dev",
|
||||||
"dev:mobile": "cross-env RUST_BACKTRACE=1 tauri dev -c src-tauri/tauri.mobile.conf.json",
|
"dev:mobile": "cross-env RUST_BACKTRACE=1 tauri dev -c src-tauri/tauri.mobile.conf.json",
|
||||||
"dev:android": "cross-env RUST_BACKTRACE=1 tauri android dev",
|
"dev:android": "cross-env RUST_BACKTRACE=1 tauri android run",
|
||||||
"log:android": "adb logcat -e \"RustStdoutStderr\"",
|
"dev:android:server": "cross-env RUST_BACKTRACE=1 tauri android dev",
|
||||||
|
"dev:android:install": "adb install -r src-tauri/gen/android/app/build/outputs/apk/arm64/debug/app-arm64-debug.apk",
|
||||||
|
"dev:android:build": "tauri android build --debug",
|
||||||
|
"dev:android:log": "adb logcat -e \"RustStdoutStderr\"",
|
||||||
"build:desktop": "tauri build",
|
"build:desktop": "tauri build",
|
||||||
"build:android": "tauri android build",
|
"build:android": "tauri android build",
|
||||||
"install:android": "adb install -r src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk",
|
"install:android": "adb install -r src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk",
|
||||||
"run:android": "tauri android run",
|
|
||||||
"build:android:debug": "tauri android build --debug",
|
|
||||||
"install:android:debug": "adb install -r src-tauri/gen/android/app/build/outputs/apk/universal/debug/app-universal-debug.apk",
|
|
||||||
"run:desktop": ".\\target\\release\\cjdic2.exe",
|
"run:desktop": ".\\target\\release\\cjdic2.exe",
|
||||||
"release": "node release.js",
|
"release": "node release.js",
|
||||||
"dev": "cd src-react && pnpm run dev",
|
"dev": "cd src-react && pnpm run dev",
|
||||||
"build": "cd src-react && pnpm run build",
|
"build": "cd src-react && pnpm run build"
|
||||||
"tauri": "tauri"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^2",
|
"@tauri-apps/cli": "^2",
|
||||||
"cross-env": "^10.1.0"
|
"cross-env": "^10.1.0",
|
||||||
|
"sharp": "^0.34.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,9 @@ importers:
|
|||||||
cross-env:
|
cross-env:
|
||||||
specifier: ^10.1.0
|
specifier: ^10.1.0
|
||||||
version: 10.1.0
|
version: 10.1.0
|
||||||
|
sharp:
|
||||||
|
specifier: ^0.34.5
|
||||||
|
version: 0.34.5
|
||||||
|
|
||||||
js-server:
|
js-server:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ android {
|
|||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
getByName("debug") {
|
getByName("debug") {
|
||||||
applicationIdSuffix = ".dev"
|
// applicationIdSuffix = ".dev"
|
||||||
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
||||||
isDebuggable = true
|
isDebuggable = true
|
||||||
isJniDebuggable = true
|
isJniDebuggable = true
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 16 KiB |
@@ -1,4 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">cjdic2 (debug)</string>
|
|
||||||
<string name="main_activity_title">cjdic2 (debug)</string>
|
|
||||||
</resources>
|
|
||||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 163 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 974 B After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 903 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 232 KiB |
|
After Width: | Height: | Size: 961 B |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 937 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 25 KiB |