Xj dZddlmZddlZddlmZddlmZddlm Z ddl m Z m Z er ddl mZdd lmZGd d e Zy) z7The proxy class for an image part, and related objects.) annotationsN) TYPE_CHECKING)Image)Part)EmuInches) OpcPackage)PackURIceZdZdZ d d fd ZedZedZedZe d dZ ed dZ e ddZ ed Z xZS) ImagePartzlAn image part. Corresponds to the target part of a relationship with type RELATIONSHIP_TYPE.IMAGE. c>tt| |||||_yN)superr __init___image)selfpartname content_typeblobimage __class__s d/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/docx/parts/image.pyrzImagePart.__init__s i',E cz|jj}|jj}||z }t|S)zkNative width of this image, calculated from its width in pixels and horizontal dots per inch (dpi).)rpx_widthhorz_dpir)rrrwidth_in_inchess r default_cxzImagePart.default_cxs7::&&::&&"X-o&&rc|jj}|jj}tt d|z|z }t |S)zkNative height of this image, calculated from its height in pixels and vertical dots per inch (dpi).i )r px_heightrintroundr)rr r height_in_emus r default_cyzImagePart.default_cy&sFJJ(( ::&&E&9"4x"?@A =!!rcx|j|jjSd|jjzS)a?Filename from which this image part was originally created. A generic name, e.g. 'image.png', is substituted if no name is available, for example when the image was loaded from an unnamed stream. In that case a default extension is applied based on the detected MIME type of the image. zimage.%s)rfilenamerextrs rr&zImagePart.filename/s3 ;; ";;'' 'DMM----rcFt||j|j|S)zZReturn an |ImagePart| instance newly created from `image` and assigned `partname`.)r rr)clsrrs r from_imagezImagePart.from_image;s5#5#5uzz5IIrcz|j$tj|j|_|jSr)rr from_blobrr(s rrzImagePart.imageAs* ;; //$))4DK{{rc||||S)zCalled by ``docx.opc.package.PartFactory`` to load an image part from a package being opened by ``Document(...)`` call.)r*rrrpackages rloadzImagePart.loadGs8\400rc\tj|jjS)z0SHA1 hash digest of the blob of this image part.)hashlibsha1r hexdigestr(s rr4zImagePart.sha1Ms ||DII&0022rr)rr rstrrbytesrz Image | None)rrrr )returnr)rr rr6rr7r0r )__name__ __module__ __qualname____doc__rpropertyrr$r& classmethodr+rr1r4 __classcell__)rs@rr r s X\/2:?HT ''"" . .JJ  11 33rr )r< __future__rr3typingrdocx.image.imager docx.opc.partr docx.sharedrrdocx.opc.packager docx.opc.packurir r r/rrrGs/=" "#+(?3?3r