diff --git a/apps/app-frontend/src/components/ui/skin/EditSkinModal.vue b/apps/app-frontend/src/components/ui/skin/EditSkinModal.vue index de0ae7132..06b45fd1d 100644 --- a/apps/app-frontend/src/components/ui/skin/EditSkinModal.vue +++ b/apps/app-frontend/src/components/ui/skin/EditSkinModal.vue @@ -118,6 +118,7 @@ import { type Cape, type SkinModel, get_normalized_skin_texture, + determineModelType, } from '@/helpers/skins.ts' import { handleError } from '@/store/notifications' import { @@ -253,7 +254,7 @@ async function showNew(e: MouseEvent, skinTextureUrl: string) { mode.value = 'new' currentSkin.value = null uploadedTextureUrl.value = skinTextureUrl - variant.value = 'CLASSIC' + variant.value = await determineModelType(skinTextureUrl) selectedCape.value = undefined visibleCapeList.value = [] initVisibleCapeList() diff --git a/apps/app-frontend/src/helpers/skins.ts b/apps/app-frontend/src/helpers/skins.ts index 28a29ba1a..9b5953f53 100644 --- a/apps/app-frontend/src/helpers/skins.ts +++ b/apps/app-frontend/src/helpers/skins.ts @@ -62,16 +62,14 @@ export async function determineModelType(texture: string): Promise<'SLIM' | 'CLA context.drawImage(image, 0, 0) - const armX = 44 - const armY = 16 - const armWidth = 4 + const armX = 54 + const armY = 20 + const armWidth = 2 const armHeight = 12 - const imageData = context.getImageData(armX, armY, armWidth, armHeight).data - - for (let y = 0; y < armHeight; y++) { - const alphaIndex = (3 + y * armWidth) * 4 + 3 - if (imageData[alphaIndex] !== 0) { + for (let index = 1; index <= imageData.length; index++) { + //every fourth value in RGBA is the alpha channel + if (index % 4 == 0 && imageData[index - 1] !== 0) { resolve('CLASSIC') return }