Skip to content

Instantly share code, notes, and snippets.

@Ruqyai
Created March 14, 2020 11:50
Show Gist options
  • Save Ruqyai/c0b5afda6b1e37e75ee7ce7c9fbb1d57 to your computer and use it in GitHub Desktop.
Save Ruqyai/c0b5afda6b1e37e75ee7ce7c9fbb1d57 to your computer and use it in GitHub Desktop.
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