添加 ItemInfoBox 和 PrimaryItemBox 类,更新 HEICFile 类以支持提取主图像 ID 和列出可用项
This commit is contained in:
@@ -1,28 +1,23 @@
|
||||
# In main.py
|
||||
from heic_file import HEICFile
|
||||
|
||||
def main():
|
||||
print("--- Processing Samsung HEIC file ---")
|
||||
samsung_heic = HEICFile('samsung.heic')
|
||||
samsung_video_data = samsung_heic.get_motion_photo_data()
|
||||
def analyze_file(filename: str):
|
||||
print(f"--- Analyzing {filename} ---")
|
||||
heic_file = HEICFile(filename)
|
||||
|
||||
# List all available items in the file
|
||||
heic_file.list_items()
|
||||
|
||||
# Get the ID of the primary image
|
||||
primary_id = heic_file.get_primary_item_id()
|
||||
if primary_id:
|
||||
print(f"\nThe primary item ID is: {primary_id}")
|
||||
|
||||
if samsung_video_data:
|
||||
output_filename = 'samsung_motion_photo.mp4'
|
||||
with open(output_filename, 'wb') as f:
|
||||
f.write(samsung_video_data)
|
||||
print(f"Successfully extracted motion photo to '{output_filename}' ({len(samsung_video_data)} bytes)")
|
||||
|
||||
print("\n" + "="*40 + "\n")
|
||||
|
||||
print("--- Processing Apple HEIC file ---")
|
||||
apple_heic = HEICFile('apple.heic')
|
||||
apple_video_data = apple_heic.get_motion_photo_data()
|
||||
|
||||
if apple_video_data:
|
||||
# This block should not be reached for Apple files
|
||||
print("Extracted embedded video from Apple file (this is unexpected).")
|
||||
else:
|
||||
print("No embedded motion photo found in Apple file, as expected.")
|
||||
|
||||
def main():
|
||||
analyze_file('apple.heic')
|
||||
analyze_file('samsung.heic')
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user