Quick actions

cmd+k|ctrl+k

Navigation

Languages

gambar manusia

Snippet info

Language

Python

Visibility

public

Author

markusparu54

Created

2024-12-09T11:15:29.84427Z

Updated

2024-12-09T11:15:43.55889Z

import os
from PIL import Image

# Path ke file gambar
file_path = "D:/daftar/sesi1/human.jpg"  # Ganti dengan lokasi file sebenarnya

# Fungsi utama untuk membuka gambar
def open_image(file_path):
    if os.path.exists(file_path):  # Periksa apakah file ada
        try:
            image = Image.open(file_path)  # Membuka file gambar
            image.show()  # Menampilkan gambar
            print(f"Berhasil membuka file: {file_path}")
        except Exception as e:
            print(f"Terjadi kesalahan saat membuka file: {e}")
    else:
        print(f"File '{file_path}' tidak ditemukan. Pastikan lokasinya benar.")

# Panggil fungsi untuk membuka gambar
open_image(file_path)
INFO