Compare commits

...

3 Commits

Author SHA1 Message Date
lamp 1323dfa8c7 Merge branch 'main' of gitea.moe:lamp/vrchat-emoji-manager 2024-10-07 15:12:26 -07:00
lamp 38cc09e7e9 Don't stretch images
Pad to square with transparency. No more restriction on aspect ratio
2024-10-07 15:12:19 -07:00
lamp c953a3be71 Don't stretch images
Pad to square with transparency. No more restriction on aspect ratio
2024-10-07 15:10:42 -07:00
3 changed files with 16 additions and 29 deletions
+10 -23
View File
@@ -96,39 +96,26 @@ async function addFiles(files) {
try { try {
let image = await loadImage(URL.createObjectURL(file)); let image = await loadImage(URL.createObjectURL(file));
/* let width = image.width; let width = image.width;
let height = image.height; let height = image.height;
const MIN = 64, MAX = 2048; const MIN = 64, MAX = 512; // VRChat API will accept and store images up to 2048x2048, but the game seems to resize everything to 512x512.
let aspectRatio = width / height; let aspectRatio = width / height;
if (aspectRatio < (MIN/MAX) || aspectRatio > (MAX/MIN)) throw new Error("Invalid aspect ratio");
if (height > width) { if (height > width) {
if (height > MAX) { height = Math.max(MIN, Math.min(MAX, height));
height = MAX;
width = height * aspectRatio; width = height * aspectRatio;
}
if (width < MIN) {
width = MIN;
height = width * (1/aspectRatio);
}
} else { } else {
if (width > MAX) { width = Math.max(MIN, Math.min(MAX, width));
width = MAX;
height = width * (1/aspectRatio); height = width * (1/aspectRatio);
} }
if (height < MIN) { let largestDim = Math.max(width, height);
height = MIN; let offsetX = (largestDim - width) / 2;
width = height * aspectRatio; let offsetY = (largestDim - height) / 2;
}
} */
// Although VRChat will store the original image within 64-2048px, it looks like the game resizes it to 512x512.
let width = 512, height = 512;
let canvas = document.createElement("canvas"); let canvas = document.createElement("canvas");
canvas.width = width; canvas.width = largestDim;
canvas.height = height; canvas.height = largestDim;
let ctx = canvas.getContext("2d"); let ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0, width, height); ctx.drawImage(image, offsetX, offsetY, width, height);
let data = canvas.toDataURL(); let data = canvas.toDataURL();
URL.revokeObjectURL(image.src); URL.revokeObjectURL(image.src);
let e = { let e = {
+2 -2
View File
@@ -1,8 +1,8 @@
{ {
"manifest_version": 3, "manifest_version": 3,
"name": "VRChat Emoji Manager", "name": "VRChat Emoji Manager",
"version": "1.2023.11.1", "version": "1.2024.10.7",
"description": "Store more than 5 emoji, toggle them on and off and change their animation styles.", "description": "Store more than 9 emoji, toggle them on and off and change their animation styles.",
"homepage_url": "https://gitea.moe/lamp/vrchat-emoji-manager", "homepage_url": "https://gitea.moe/lamp/vrchat-emoji-manager",
"icons": { "icons": {
"128": "icon128.png" "128": "icon128.png"
+1 -1
View File
@@ -1,6 +1,6 @@
# VRChat Emoji Manager # VRChat Emoji Manager
VRChat Plus has a custom emoji feature but it is limited to 5 emojis and you cannot change their animation styles. This Chrome extension allows you to have a much larger collection of emojis and conveniently toggle them on and off when needed. VRChat Plus has a custom emoji feature but it is limited to 9 emojis and you cannot change their animation styles. This Chrome extension allows you to have a much larger collection of emojis and conveniently toggle them on and off when needed.
![image](2023-10-26_20-50-20-123%20VRChat_Emoji_Manager_-_Google_Chrome.png) ![image](2023-10-26_20-50-20-123%20VRChat_Emoji_Manager_-_Google_Chrome.png)