Created
March 14, 2020 11:50
-
-
Save Ruqyai/c0b5afda6b1e37e75ee7ce7c9fbb1d57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image # مكتبة بايثون للصور ايضا | |
import os, sys # للوصول والتعامل مع الملفات في النظام والسستم | |
path = "/content/" # المسار الذي توجد به الصور | |
dirs = os.listdir( path ) # ترجع كل محتويات المسار | |
# فنكشن (دالة) توحيد الأحجام | |
def resize(): | |
for item in dirs: | |
if os.path.isfile(path+item): | |
im = Image.open(path+item) | |
f, e = os.path.splitext(path+item) # تفصل اسم الملف عن امتداده | |
imResize = im.resize((200,200), Image.ANTIALIAS) # اعادة حجم الصورة | |
imResize.save(f+ '.jpg', 'JPEG', quality=90)# نحفظ الصورة بنفس اسمها السابق | |
resize() # تشغيل الفنكشن _الدالة |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment