Image
الفئة: Image
Properties: aspose.note Properties: from aspose.note import Image Properties: CompositeNode
Image يمثل صورة مدمجة مخزنة داخل OneNote .one ملف. يكشف عن raw image bytes، original filename، rendered dimensions، alt text، hyperlink URL (إن وجد)، وأي OneNote tags المرتبطة بالصورة.
Properties
| Properties | Properties | Properties | Properties |
|---|---|---|---|
FileName | `str | None` | Properties |
Bytes | bytes | Properties | بيانات الصورة الخام (PNG، JPEG، أو أي تنسيق ثنائي آخر حسب المصدر) |
Width | `float | None` | Properties |
Height | `float | None` | Properties |
AlternativeTextTitle | `str | None` | Properties |
AlternativeTextDescription | `str | None` | Properties |
HyperlinkUrl | `str | None` | Properties |
Tags | list[NoteTag] | Properties | علامات OneNote المرفقة بهذه الصورة |
موروث من CompositeNode / Node
| Properties | Properties |
|---|---|
ParentNode | العقدة المحتوية (OutlineElement، TableCell) |
Document | المستند الجذر |
Properties
Replace(image)
img.Replace(image: Image) -> Noneيستبدل محتوى هذا Image العقدة بمحتوى عقدة أخرى Image العقدة، في الذاكرة. حفظ العودة إلى .one غير مدعوم.
Accept(visitor)
img.Accept(visitor: DocumentVisitor) -> NoneProperties VisitImageStart(img) و VisitImageEnd(img) على الزائر.
أمثلة الاستخدام
احفظ جميع الصور على القرص
from aspose.note import Document, Image
doc = Document("MyNotes.one")
for i, img in enumerate(doc.GetChildNodes(Image), start=1):
filename = img.FileName or f"image_{i}.bin"
with open(filename, "wb") as f:
f.write(img.Bytes)
print(f"Saved: {filename} ({img.Width} x {img.Height} pts)")اكتشف تنسيق الصورة من البايتات
from aspose.note import Document, Image
doc = Document("MyNotes.one")
for img in doc.GetChildNodes(Image):
b = img.Bytes
if b[:4] == b'\x89PNG':
fmt = "png"
elif b[:2] == b'\xff\xd8':
fmt = "jpeg"
elif b[:4] == b'GIF8':
fmt = "gif"
else:
fmt = "bin"
print(f" {img.FileName!r} detected as {fmt}")اعثر على جميع الصور المرتبطة
from aspose.note import Document, Image
doc = Document("MyNotes.one")
for img in doc.GetChildNodes(Image):
if img.HyperlinkUrl:
print(f" Linked image: {img.FileName!r} -> {img.HyperlinkUrl}")قراءة النص البديل
from aspose.note import Document, Image
doc = Document("MyNotes.one")
for img in doc.GetChildNodes(Image):
if img.AlternativeTextTitle or img.AlternativeTextDescription:
print(f" Alt title: {img.AlternativeTextTitle!r}")
print(f" Alt desc: {img.AlternativeTextDescription!r}")فحص الوسوم على الصور
from aspose.note import Document, Image
doc = Document("MyNotes.one")
for img in doc.GetChildNodes(Image):
for tag in img.Tags:
print(f" Image tag: label={tag.label!r} completed={tag.completed}")الصور لكل صفحة
from aspose.note import Document, Page, Image
doc = Document("MyNotes.one")
for page_num, page in enumerate(doc.GetChildNodes(Page), start=1):
images = page.GetChildNodes(Image)
print(f"Page {page_num}: {len(images)} image(s)")أمان None
FileNameهوNoneعند عدم تخزين اسم ملف: احرص دائمًا على توفير بديل عند الكتابة إلى القرص.Bytesدائمًا ما يكونbytesكائن ولا يكون أبدًاNone.WidthوHeightهيNoneللصور التي لا تحتوي على بيانات أبعاد.AlternativeTextTitle,AlternativeTextDescription,، وHyperlinkUrlهيNoneعند عدم تعيينه.
انظر أيضًا
- AttachedFile: مرفقات ملفات مدمجة
- NoteTag: وسوم على الصور
- Properties: سلف Image
- دليل المطور للصور والملفات المرفقة
- كيفية: استعراض DOM (KB)