Image
क्लास: Image
ImageRenderOptions: aspose.note ImageRenderOptions: from aspose.note import Image ImageRenderOptions: CompositeNode
Image OneNote के भीतर संग्रहीत एक एम्बेडेड छवि का प्रतिनिधित्व करता है .one फ़ाइल। यह कच्चे छवि बाइट्स, मूल फ़ाइलनाम, रेंडर किए गए आयाम, alt text, एक हाइपरलिंक URL (यदि कोई हो), और छवि से जुड़े किसी भी OneNote टैग को उजागर करता है।.
ImageRenderOptions
| Name | Type | Access | Description |
|---|---|---|---|
FileName | `str | None` | Read |
FilePath | `str | None` | Read |
Format | `str | None` | Read |
Bytes | bytes | Read | Gets the bytes. |
OriginalWidth | `float | None` | Read |
OriginalHeight | `float | None` | Read |
Tags | list[NoteTag] | Read | Gets the tags. |
Alignment | `HorizontalAlignment | None` | Read/Write |
Width | `` | Read | Gets the width. |
Height | `` | Read | Gets the height. |
HorizontalOffset | `` | Read | Gets the horizontal offset. |
VerticalOffset | `` | Read | Gets the vertical offset. |
IsBackground | `` | Read | Gets the is background. |
LastModifiedTime | `` | Read | Gets the last modified time. |
AlternativeTextTitle | `` | Read | Gets the alternative text title. |
AlternativeTextDescription | `` | Read | Gets the alternative text description. |
HyperlinkUrl | `` | Read | Gets the hyperlink url. |
FirstChild | `Node | None` | Read |
LastChild | `Node | None` | Read |
ParentNode | `Node | None` | Read |
Document | `Document | None` | Read |
CompositeNode / Node से इनहेरिटेड
| Signature | Description |
|---|---|
| `init(FileName: str | None, FilePath: str |
Replace(image: Image) | Replaces the current image data with the provided Image instance |
AppendChildLast(node: TNode) → TNode | |
AppendChildFirst(node: TNode) → TNode | |
InsertChild(index: int, node: TNode) → TNode | |
RemoveChild(node: Node) | |
GetEnumerator() → Iterator[Node] | |
GetChildNodes(node_type: type[TNode]) → list[TNode] | |
Accept(visitor: DocumentVisitor) |
ImageRenderOptions
Replace(image)
img.Replace(image: Image) -> Noneइसकी सामग्री को प्रतिस्थापित करता है Image दूसरे नोड की सामग्री वाला नोड Image नोड, मेमोरी में। वापस सहेजना .one समर्थित नहीं है।.
Accept(visitor)
img.Accept(visitor: DocumentVisitor) -> NoneImageRenderOptions 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)")बाइट्स से इमेज फ़ॉर्मेट का पता लगाएँ
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}")
### सभी लिंक्ड इमेज खोजें
doc = Document("MyNotes.one")
for img in doc.GetChildNodes(Image):
if img.HyperlinkUrl:
print(f" Linked image: {img.FileName!r} -> {img.HyperlinkUrl}")alt टेक्स्ट पढ़ें
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}")
### इमेज पर टैग्स का निरीक्षण करें
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: छवियों पर टैग्स
- ImageRenderOptions: Image का पूर्वज
- Images और Attached Files डेवलपर गाइड
- How-to: DOM को ट्रैवर्स करें (KB)