File size: 1,942 Bytes
70eedf8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "d6a916d2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "npc.png 리사이즈 완료\n"
     ]
    }
   ],
   "source": [
    "# 이미지 크기 64x64로 변경 (input_images -> resized_images)\n",
    "from PIL import Image\n",
    "import os\n",
    "\n",
    "# 입력 폴더와 출력 폴더 경로 설정\n",
    "input_folder = \"input_images/set_2\"   # 원본 이미지 폴더\n",
    "output_folder = \"resized_images\"    # 리사이즈된 이미지 저장 폴더\n",
    "target_size = (64, 64)\n",
    "\n",
    "# 출력 폴더가 없으면 생성\n",
    "os.makedirs(output_folder, exist_ok=True)\n",
    "\n",
    "# 이미지 리사이즈\n",
    "for filename in os.listdir(input_folder):\n",
    "    if filename.lower().endswith((\".png\", \".jpg\", \"jpeg\", \".bmp\", \".gif\")):\n",
    "        input_path = os.path.join(input_folder, filename)\n",
    "        output_path = os.path.join(output_folder, filename)\n",
    "\n",
    "        try:\n",
    "            with Image.open(input_path) as img:\n",
    "                resized_img = img.resize(target_size, Image.Resampling.LANCZOS)\n",
    "                resized_img.save(output_path)\n",
    "                print(f\"{filename} 리사이즈 완료\")\n",
    "        except Exception as e:\n",
    "            print(f\"{filename} 처리 중 오류 발생: {e}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "portfolio",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}