コード例 #1
0
ファイル: raw.py プロジェクト: marcelgaedke/ImageConverter
    def save(self, filename=None, filetype=None):
        """
        Save the image data as a new PPM or TIFF image.

        Args:
            filename (str): The name of an image file to save.
            filetype (output_file_types): The type of file to output. By
                                          default, guess based on the filename,
                                          falling back to PPM.

        Raises:
            rawkit.errors.NoFileSpecified: If `filename` is ``None``.
            rawkit.errors.InvalidFileType: If `filetype` is not None or in
                                           :class:`output_file_types`.
        """
        if filename is None:
            raise NoFileSpecified()

        if filetype is None:
            ext = os.path.splitext(filename)[-1].lower()[1:]
            filetype = ext or output_file_types.ppm

        if filetype not in output_file_types:
            raise InvalidFileType(
                "Output filetype must be in raw.output_file_types")

        self.data.contents.params.output_tiff = (
            filetype == output_file_types.tiff)

        self.unpack()
        self.process()

        self.libraw.libraw_dcraw_ppm_tiff_writer(self.data,
                                                 filename.encode('ascii'))
コード例 #2
0
ファイル: raw.py プロジェクト: marcelgaedke/ImageConverter
    def __init__(self, filename=None):
        """Initializes a new Raw object."""
        if filename is None:
            raise NoFileSpecified()
        self.libraw = LibRaw()
        self.data = self.libraw.libraw_init(0)
        self.libraw.libraw_open_file(self.data, filename.encode('ascii'))

        self.options = Options()

        self.image_unpacked = False
        self.thumb_unpacked = False
コード例 #3
0
ファイル: raw.py プロジェクト: hashrc/rawkit-1
    def __init__(self, filename=None):
        """Initializes a new Raw object."""
        if filename is None:
            raise NoFileSpecified()
        self.libraw = LibRaw()
        self.data = self.libraw.libraw_init(0)
        try:  # pragma: no cover
            _fname = os.fsencode(filename)
        except Exception:  # pragma: no cover
            _fname = filename
        self.libraw.libraw_open_file(self.data, _fname)

        self.options = Options()

        self.image_unpacked = False
        self.thumb_unpacked = False
コード例 #4
0
ファイル: raw.py プロジェクト: marcelgaedke/ImageConverter
    def save_thumb(self, filename=None):
        """
        Save the thumbnail data.

        Args:
            filename (str): The name of an image file to save.

        Raises:
            rawkit.errors.NoFileSpecified: If `filename` is ``None``.
        """
        if filename is None:
            raise NoFileSpecified()

        self.unpack_thumb()

        self.libraw.libraw_dcraw_thumb_writer(self.data,
                                              filename.encode('ascii'))
コード例 #5
0
ファイル: raw.py プロジェクト: hashrc/rawkit-1
    def save_thumb(self, filename=None):
        """
        Save the thumbnail data.

        Args:
            filename (str): The name of an image file to save.

        Raises:
            rawkit.errors.NoFileSpecified: If `filename` is ``None``.
        """
        if filename is None:
            raise NoFileSpecified()

        self.unpack_thumb()

        try:  # pragma: no cover
            _fname = os.fsencode(filename)
        except Exception:  # pragma: no cover
            _fname = filename
        self.libraw.libraw_dcraw_thumb_writer(self.data, _fname)