ysn-rfd/text-dataset-tiny-code-script-py-format
USED of tahamajs/medicine_ds_persian for .parquet file USED of Alijafarixcs2/persian-it-llama2-2k for .parquet file USED of Abirate/english_quotes for .jsonl file NEW FILES (05/12/2025) NEW FILES (12/26/2025) NEW FILES (02/15/2026)
31.7k
1from PIL import Image, ExifTags
2from collections import Counter
3import os
4
5def extract_image_info(image_path):
6 if not os.path.exists(image_path):
7 print("فایل وجود ندارد!")
8 return
9
10 with Image.open(image_path) as img:
11 print("======== اطلاعات کلی ========")
12 print(f"فرمت: {img.format}")
13 print(f"ابعاد: {img.size} (عرض × ارتفاع)")
14 print(f"مود رنگی: {img.mode}")
15 print(f"اطلاعات DPI: {img.info.get('dpi', 'نامشخص')}")
16 print(f"دارای Alpha channel: {'A' in img.mode}")
17 print(f"اطلاعات دیگر: {img.info}")
18
19 print("\n======== رنگ غالب و میانگین ========")
20 img_rgb = img.convert('RGB')
21 pixels = list(img_rgb.getdata())
22 most_common = Counter(pixels).most_common(1)[0][0]
23 average_color = tuple(sum(x) // len(x) for x in zip(*pixels))
24 print(f"رنگ غالب: {most_common}")
25 print(f"میانگین رنگ: {average_color}")
26
27 print("\n======== هیستوگرام رنگی ========")
28 hist = img.histogram()
29 print(f"تعداد مقادیر هیستوگرام: {len(hist)}")
30
31 print("\n======== اطلاعات EXIF ========")
32 try:
33 exif_data = img._getexif()
34 if exif_data:
35 for tag, value in exif_data.items():
36 tag_name = ExifTags.TAGS.get(tag, tag)
37 print(f"{tag_name}: {value}")
38 else:
39 print("هیچ اطلاعات EXIF وجود ندارد.")
40 except Exception as e:
41 print(f"خطا در خواندن EXIF: {e}")
42
43# ======= اجرا =======
44path = "0002.png" # مسیر تصویر خود را اینجا وارد کنید
45extract_image_info(path)
46 