# 이미지 파일에서 앱 아이콘 생성 param( [Parameter(Mandatory=$false)] [string]$ImagePath = "logo.png" ) Write-Host "LS 타라유텍 앱 아이콘 생성 중..." -ForegroundColor Green Write-Host "" if (-not (Test-Path $ImagePath)) { Write-Host "오류: 이미지 파일을 찾을 수 없습니다: $ImagePath" -ForegroundColor Red Write-Host "" Write-Host "사용법:" -ForegroundColor Yellow Write-Host " 1. LS 로고 이미지를 'logo.png'로 저장" -ForegroundColor Cyan Write-Host " 2. 이 스크립트 실행: .\create-icon-from-image.ps1" -ForegroundColor Cyan Write-Host "" Write-Host "또는 이미지 경로 지정:" -ForegroundColor Yellow Write-Host " .\create-icon-from-image.ps1 -ImagePath 'path/to/image.png'" -ForegroundColor Cyan exit 1 } # Python 설치 확인 $python = Get-Command python -ErrorAction SilentlyContinue if (-not $python) { Write-Host "Python이 설치되지 않았습니다." -ForegroundColor Red Write-Host "Python을 설치해주세요: https://www.python.org/downloads/" -ForegroundColor Yellow exit 1 } # Python 스크립트 생성 $pythonScript = @" from PIL import Image import os import sys # 이미지 경로 image_path = sys.argv[1] if len(sys.argv) > 1 else 'logo.png' if not os.path.exists(image_path): print(f'오류: 이미지 파일을 찾을 수 없습니다: {image_path}') sys.exit(1) # 원본 이미지 열기 print(f'이미지 로드 중: {image_path}') original = Image.open(image_path) # RGBA 모드로 변환 if original.mode != 'RGBA': original = original.convert('RGBA') print(f'원본 이미지 크기: {original.size}') # 아이콘 크기 sizes = { 'mdpi': 48, 'hdpi': 72, 'xhdpi': 96, 'xxhdpi': 144, 'xxxhdpi': 192 } # 디렉토리 생성 base_path = 'android/app/src/main/res' for density in sizes.keys(): dir_path = f'{base_path}/mipmap-{density}' os.makedirs(dir_path, exist_ok=True) print('') print('아이콘 생성 중...') # 정사각형으로 만들기 (LS 로고 부분만 크롭) width, height = original.size # LS 부분만 추출 (왼쪽 부분) # 이미지의 왼쪽 1/3 정도만 사용 crop_width = int(width * 0.4) # LS 부분만 left = 0 top = 0 right = crop_width bottom = height # 크롭 cropped = original.crop((left, top, right, bottom)) # 정사각형으로 만들기 (패딩 추가) max_size = max(cropped.size) square = Image.new('RGBA', (max_size, max_size), (255, 255, 255, 0)) # 중앙 정렬 paste_x = (max_size - cropped.size[0]) // 2 paste_y = (max_size - cropped.size[1]) // 2 square.paste(cropped, (paste_x, paste_y)) # 각 크기별 아이콘 생성 for density, size in sizes.items(): print(f'생성 중: mipmap-{density} ({size}x{size})') # 리사이즈 (고품질) resized = square.resize((size, size), Image.Resampling.LANCZOS) # 일반 아이콘 resized.save(f'{base_path}/mipmap-{density}/ic_launcher.png', 'PNG') # 둥근 아이콘 # 둥근 마스크 생성 mask = Image.new('L', (size, size), 0) from PIL import ImageDraw draw = ImageDraw.Draw(mask) draw.ellipse([0, 0, size, size], fill=255) # 마스크 적용 round_icon = Image.new('RGBA', (size, size), (255, 255, 255, 0)) round_icon.paste(resized, (0, 0)) round_icon.putalpha(mask) round_icon.save(f'{base_path}/mipmap-{density}/ic_launcher_round.png', 'PNG') print('') print('✓ 아이콘 생성 완료!') print('') print('생성된 파일:') for density in sizes.keys(): print(f' - mipmap-{density}/ic_launcher.png') print(f' - mipmap-{density}/ic_launcher_round.png') "@ # Python 스크립트 저장 $pythonScript | Out-File -FilePath "create_icons_from_image.py" -Encoding UTF8 # Pillow 설치 Write-Host "Pillow 라이브러리 확인 중..." -ForegroundColor Cyan python -m pip install --upgrade pip --quiet 2>$null python -m pip install Pillow --quiet 2>$null # 아이콘 생성 실행 Write-Host "" Write-Host "아이콘 생성 실행 중..." -ForegroundColor Cyan python create_icons_from_image.py $ImagePath if ($LASTEXITCODE -eq 0) { Write-Host "" Write-Host "========================================" -ForegroundColor Green Write-Host "✓ LS 타라유텍 아이콘 생성 완료!" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Green Write-Host "" Write-Host "다음 명령어로 APK를 빌드하세요:" -ForegroundColor Yellow Write-Host " cd android" -ForegroundColor Cyan Write-Host " .\gradlew.bat assembleDebug" -ForegroundColor Cyan Write-Host "" # 임시 파일 삭제 Remove-Item "create_icons_from_image.py" -ErrorAction SilentlyContinue } else { Write-Host "" Write-Host "오류가 발생했습니다." -ForegroundColor Red }