Skip to content

Commit 0a6c061

Browse files
committed
backup
1 parent a924e45 commit 0a6c061

File tree

5 files changed

+303
-0
lines changed

5 files changed

+303
-0
lines changed

image_metadata_modify/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Image Meta Dataset
2+
3+
## Proje Hakkında
4+
5+
**Image Metadata Dataset**, görüntü dosyalarının meta verilerini okuma, silme ve yönetme işlemlerini kolaylaştıran bir Python projesidir. Bu proje, Pillow ve Piexif kütüphanelerini kullanarak görüntü dosyalarının EXIF verilerini işler. Proje, kullanıcıların görüntü dosyalarının meta verilerini kolayca görüntülemesine ve düzenlemesine olanak tanır.
6+
7+
## Özellikler
8+
9+
- **Meta Veri Görüntüleme**: Görüntü dosyalarının mevcut meta verilerini görüntüler.
10+
- **Meta Veri Silme**: Görüntü dosyalarından meta verileri siler ve yeni bir dosya olarak kaydeder.
11+
- **Kullanıcı Dostu Arayüz**: Kullanıcıların işlemleri kolayca gerçekleştirmesine olanak tanır.
12+
- **Desteklenen Formatlar**: JPEG, PNG gibi yaygın görüntü formatlarını destekler.
13+
14+
## UV Entegrasyonu
15+
16+
**UV**, Rust ile yazılmış, son derece hızlı bir Python paket ve proje yöneticisidir. [Ziyaret et](https://docs.astral.sh/uv/).
17+
18+
## Kurulum
19+
20+
Projeyi kullanmak için aşağıdaki adımları izleyin:
21+
22+
1. **Python Kurulumu**: Projeyi çalıştırmak için Python 3.x gereklidir.
23+
24+
2. **Gerekli Kütüphanelerin Kurulumu**:
25+
```bash
26+
pip install pillow piexif
27+
```
28+
29+
3. Projeyi Klonlama:
30+
```bash
31+
git clone https://github.com/Mefamex/image-meta-dataset.git
32+
cd image-meta-dataset
33+
```
34+
35+
## Kullanım
36+
37+
Projeyi kullanmak için aşağıdaki adımları izleyin:
38+
39+
1. Meta Veri Görüntüleme:
40+
```python
41+
from metadata_manager import display_metadata
42+
display_metadata("path/to/your/image.jpg")
43+
```
44+
45+
2. Meta Veri Silme:
46+
```python
47+
from metadata_manager import delete_image_metadata
48+
delete_image_metadata("path/to/your/image.jpg", "path/to/output/image.jpg")
49+
```
50+
51+
## Örnek Kullanım
52+
```python
53+
image_path = "a.jpg"
54+
output_path = "aa.jpg"
55+
display_metadata(image_path)
56+
delete_image_metadata(image_path, output_path)
57+
display_metadata(output_path)
58+
```
59+
60+
## Lisans
61+
62+
Bu proje [MIT Lisansı](LICENSE) altında lisanslanmıştır.
63+
64+
## İletişim
65+
66+
Proje ile ilgili herhangi bir sorunuz veya öneriniz varsa, lütfen benimle [iletişime geçin](https://mefamex.com/contact/).
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# -*- coding: utf-8 -*-
2+
# Created on Friday, July 19 15:30:00 2024
3+
# @author: mefamex
4+
5+
# project_name = "image-meta-dataset"
6+
# project_version = "1.0.0"
7+
# project_author = "Mefamex"
8+
# project_date = "29.01.2025"
9+
# project_description = "This is a project description"
10+
# project_license = "MIT"
11+
# project_repository = "https://github.com/Mefamex/image-meta-dataset"
12+
# project_url = "https://mefamex.com/projects/image-meta-dataset"
13+
14+
# pip install piexif pillow
15+
from PIL import Image
16+
import os, piexif, piexif.helper
17+
18+
print("----------------------------------------\n"+os.getcwd())
19+
print(os.path.dirname(os.path.realpath(__file__)))
20+
print(os.path.dirname(os.path.abspath(__file__)))
21+
print(__file__)
22+
print("Pillow Version:", Image.__version__, "\n----------------------------------------\n")
23+
24+
from PIL import Image
25+
import os, piexif, piexif.helper
26+
27+
28+
29+
def display_metadata(image_path):
30+
if not os.path.exists(image_path):
31+
print(f"Hata: {image_path} bulunamadı.")
32+
return
33+
34+
image = Image.open(image_path)
35+
exif_bytes = image.info.get("exif")
36+
exif_data = piexif.load(exif_bytes) if exif_bytes else {"0th": {}, "Exif": {}, "GPS": {}, "Interop": {}, "1st": {}, "thumbnail": None}
37+
38+
print("Mevcut Metadata:")
39+
for ifd in exif_data:
40+
if exif_data[ifd] is None or isinstance(exif_data[ifd], bytes):
41+
continue
42+
for tag, value in exif_data[ifd].items():
43+
try:
44+
if isinstance(value, bytes):
45+
value = value.decode(errors='ignore')
46+
print(f"{piexif.TAGS[ifd][tag]['name']}: {value}")
47+
except KeyError:
48+
print(f"{tag}: {value}")
49+
print("............................................")
50+
51+
52+
def delete_image_metadata(image_path, output_path):
53+
if not os.path.exists(image_path):
54+
print(f"Hata: {image_path} bulunamadı.")
55+
return
56+
image = Image.open(image_path)
57+
exif_bytes = image.info.get("exif")
58+
exif_data = piexif.load(exif_bytes) if exif_bytes else {"0th": {}, "Exif": {}, "GPS": {}, "Interop": {}, "1st": {}, "thumbnail": None}
59+
exif_bytes = piexif.dump(exif_data)
60+
image.save(output_path, exif=exif_bytes)
61+
print(f"{image_path} dosyasındaki metadata başarıyla silindi ve {output_path} dosyasına kaydedildi.")
62+
print("............................................")
63+
64+
65+
# Örnek Kullanım
66+
image_path = "a.jpg"
67+
output_path = "aa.jpg"
68+
display_metadata(image_path)
69+
delete_image_metadata(image_path, output_path)
70+
display_metadata(output_path)

image_metadata_modify/recoop.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from PIL import Image
2+
from PIL.ExifTags import TAGS
3+
4+
def get_exif_data(image):
5+
exif_data = image._getexif()
6+
if exif_data is not None:
7+
for tag, value in exif_data.items():
8+
tag_name = TAGS.get(tag, tag)
9+
exif_data[tag_name] = exif_data.pop(tag)
10+
return exif_data
11+
else:
12+
return None
13+
14+
def display_metadata(metadata):
15+
if metadata:
16+
print("Mevcut Meta Veriler:")
17+
for key, value in metadata.items():
18+
print(f"{key}: {value}")
19+
else:
20+
print("Resimde meta veri bulunmuyor.")
21+
22+
def modify_metadata(metadata):
23+
if metadata:
24+
print("\nMeta Verileri Değiştir (Boş bırakmak için Enter'a basın):")
25+
for key in metadata.keys():
26+
new_value = input(f"{key}: ")
27+
if new_value:
28+
metadata[key] = new_value
29+
return metadata
30+
31+
def add_metadata(metadata):
32+
if metadata is None:
33+
metadata = {}
34+
print("\nEklemek İstediğiniz Meta Verileri Girin (Boş bırakmak için Enter'a basın):")
35+
while True:
36+
key = input("Anahtar (örn. 'Subject'): ")
37+
if not key:
38+
break
39+
value = input("Değer: ")
40+
if not value:
41+
break
42+
metadata[key] = value
43+
return metadata
44+
45+
def save_metadata(image_path, metadata):
46+
image = Image.open(image_path)
47+
exif_data = image._getexif()
48+
if exif_data is None:
49+
exif_data = {}
50+
for key, value in metadata.items():
51+
tag_id = get_tag_id(key)
52+
if tag_id:
53+
exif_data[tag_id] = value
54+
image.save(image_path, exif=exif_data)
55+
print(f"Meta veriler '{image_path}' dosyasına kaydedildi.")
56+
57+
def get_tag_id(tag_name):
58+
for tag, tag_id in TAGS.items():
59+
if TAGS.get(tag, tag) == tag_name:
60+
return tag
61+
return None
62+
63+
if __name__ == "__main__":
64+
image_path = input("Resim dosyasının yolunu girin: ")
65+
try:
66+
image = Image.open(image_path)
67+
metadata = get_exif_data(image)
68+
display_metadata(metadata)
69+
metadata = modify_metadata(metadata)
70+
metadata = add_metadata(metadata)
71+
save_metadata(image_path, metadata)
72+
except FileNotFoundError:
73+
print("Dosya bulunamadı.")
74+
except Exception as e:
75+
print(f"Bir hata oluştu: {e}")
76+
77+

image_metadata_modify/recoop1.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from PIL import Image
2+
import piexif
3+
4+
def get_image_metadata(image_path):
5+
"""Retrieve and display the current metadata of the image."""
6+
image = Image.open(image_path)
7+
exif_data = image._getexif()
8+
metadata = {}
9+
10+
if exif_data is not None:
11+
for tag_id, value in exif_data.items():
12+
tag = piexif.TAGS.get(tag_id, tag_id)
13+
metadata[tag] = value
14+
15+
return metadata
16+
17+
def modify_image_metadata(image_path, output_path):
18+
"""Modify existing metadata and add new metadata to the image."""
19+
# Step 1: Display existing metadata
20+
print("Current Metadata:")
21+
metadata = get_image_metadata(image_path)
22+
for key, value in metadata.items():
23+
print(f"{key}: {value}")
24+
25+
# Step 2: Modify existing metadata
26+
print("\nEnter new values for the existing metadata (leave blank to keep current value):")
27+
new_metadata = {}
28+
for key in metadata.keys():
29+
new_value = input(f"{key} (current: {metadata[key]}): ")
30+
if new_value:
31+
new_metadata[key] = new_value
32+
33+
# Step 3: Add new metadata
34+
print("\nAdd any new metadata (key:value format, type 'done' to finish):")
35+
while True:
36+
new_entry = input("New Metadata Entry: ")
37+
if new_entry.lower() == 'done':
38+
break
39+
try:
40+
key, value = new_entry.split(':')
41+
new_metadata[key.strip()] = value.strip()
42+
except ValueError:
43+
print("Invalid format. Please use 'key:value' format.")
44+
45+
# Load the image and existing EXIF data
46+
image = Image.open(image_path)
47+
exif_dict = piexif.load(image.info['exif'])
48+
49+
# Update the EXIF data with new values
50+
for tag, value in new_metadata.items():
51+
if tag in exif_dict['0th']:
52+
exif_dict['0th'][tag] = value
53+
54+
# Convert the modified EXIF data back to bytes
55+
exif_bytes = piexif.dump(exif_dict)
56+
57+
# Save the image with the new EXIF data
58+
image.save(output_path, exif=exif_bytes)
59+
print(f"Modified image saved as: {output_path}")
60+
61+
# Example usage
62+
if __name__ == "__main__":
63+
image_path = 'input_image.jpg' # Replace with your image path
64+
output_path = 'output_image.jpg' # Output path for the modified image
65+
modify_image_metadata(image_path, output_path)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ffmpeg -i "[link]"-c:v libx264 -preset ultrafast -crf [1-30 (its for quality, 1 is the best quality] [create video name with].mp4
2+
3+
# :: for example ffmpeg -i https://example.site/720p.m3u8 -c:v libx264 -preset ultrafast -crf 1 720p-film.mp4
4+
5+
6+
7+
import requests
8+
import subprocess
9+
10+
11+
input_url = 'link here'
12+
output_file = 'output.mp4'
13+
14+
# Spoof user agent to avoid HTTP 403 Forbidden
15+
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)Chrome/91.0.4472.124 Safari/537.36','Referer': 'https://developer.mozilla.org/en-US/docs/Web/JavaScript' }
16+
17+
# Download HLS playlist with spoofed user agent
18+
response = requests.get(input_url)
19+
20+
if response.status_code == 200:
21+
# Use FFmpeg to process HLS playlist and create MP4 output
22+
ffmpeg_command = f'ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i {input_url} -c copy {output_file}'
23+
subprocess.run(ffmpeg_command, shell=True)
24+
else:
25+
print(f"Failed to retrieve the playlist. Status code: {response.status_code}")

0 commit comments

Comments
 (0)