0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ディレクトリ内ディレクトリ内ファイルを(Recursiveに)一括リサイズ

0
Last updated at Posted at 2020-10-25

ディレクトリの中に複数ディレクトリがあって、それぞれに画像ファイルが入っていて、その全てに処理をかけたい場合こうします。

pc_folder-tree_36537-300x300.jpg


import os
from PIL import Image

rootdir = './parentDirectory'

for subdir, dirs, files in os.walk(rootdir):
    for file in files:
      img = Image.open(os.path.join(subdir, file))
      img_resize = img.resize((256, 256), Image.LANCZOS)
      img_resize.save('./resized/' + file)

🐣


お仕事のご相談こちらまで
rockyshikoku@gmail.com

Core MLを使ったアプリを作っています。
機械学習関連の情報を発信しています。

Twitter
Medium

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?