• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pillow.PillowImage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中willow.plugins.pillow.PillowImage的典型用法代码示例。如果您正苦于以下问题:Python PillowImage类的具体用法?Python PillowImage怎么用?Python PillowImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了PillowImage类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     with open('tests/images/people.jpg', 'rb') as f:
         # Open the image via Pillow
         pillow_image = PillowImage.open(JPEGImageFile(f))
         buffer_rgb = pillow_image.to_buffer_rgb()
         colour_image = OpenCVColorImage.from_buffer_rgb(buffer_rgb)
         self.image = OpenCVGrayscaleImage.from_color(colour_image)
开发者ID:KarimJedda,项目名称:Willow,代码行数:7,代码来源:test_opencv.py


示例2: test_jpeg_with_orientation_8

    def test_jpeg_with_orientation_8(self):
        with open('tests/images/orientation/landscape_8.jpg', 'rb') as f:
            image = PillowImage.open(JPEGImageFile(f))

        image = image.auto_orient()

        self.assert_orientation_landscape_image_is_correct(image)
开发者ID:torchbox,项目名称:Willow,代码行数:7,代码来源:test_pillow.py


示例3: test_resize_animated_gif

    def test_resize_animated_gif(self):
        with open('tests/images/newtons_cradle.gif', 'rb') as f:
            image = PillowImage.open(GIFImageFile(f))

        resized_image = image.resize((100, 75))

        self.assertFalse(resized_image.has_alpha())
        self.assertTrue(resized_image.has_animation())
开发者ID:torchbox,项目名称:Willow,代码行数:8,代码来源:test_pillow.py


示例4: test_save_transparent_gif

    def test_save_transparent_gif(self):
        with open('tests/images/transparent.gif', 'rb') as f:
            image = PillowImage.open(GIFImageFile(f))

        # Save it into memory
        f = io.BytesIO()
        image.save_as_gif(f)

        # Reload it
        f.seek(0)
        image = PillowImage.open(GIFImageFile(f))

        self.assertTrue(image.has_alpha())
        self.assertFalse(image.has_animation())

        # Check that the alpha of pixel 1,1 is 0
        self.assertEqual(image.image.convert('RGBA').getpixel((1, 1))[3], 0)
开发者ID:torchbox,项目名称:Willow,代码行数:17,代码来源:test_pillow.py


示例5: test_transparent_gif

    def test_transparent_gif(self):
        with open('tests/images/transparent.gif', 'rb') as f:
            image = PillowImage.open(GIFImageFile(f))

        self.assertTrue(image.has_alpha())
        self.assertFalse(image.has_animation())

        # Check that the alpha of pixel 1,1 is 0
        self.assertEqual(image.image.convert('RGBA').getpixel((1, 1))[3], 0)
开发者ID:torchbox,项目名称:Willow,代码行数:9,代码来源:test_pillow.py


示例6: test_save_as_gif_converts_back_to_supported_mode

    def test_save_as_gif_converts_back_to_supported_mode(self):
        output = io.BytesIO()

        with open('tests/images/transparent.gif', 'rb') as f:
            image = PillowImage.open(GIFImageFile(f))
            image.image = image.image.convert('RGB')

        image.save_as_gif(output)
        output.seek(0)

        image = _PIL_Image().open(output)
        self.assertEqual(image.mode, 'P')
开发者ID:torchbox,项目名称:Willow,代码行数:12,代码来源:test_pillow.py


示例7: test_open_webp_w_alpha

    def test_open_webp_w_alpha(self):
        with open('tests/images/tux_w_alpha.webp', 'rb') as f:
            image = PillowImage.open(WebPImageFile(f))

        self.assertTrue(image.has_alpha())
        self.assertFalse(image.has_animation())
开发者ID:torchbox,项目名称:Willow,代码行数:6,代码来源:test_pillow.py


示例8: setUp

 def setUp(self):
     with open('tests/images/transparent.png', 'rb') as f:
         self.image = PillowImage.open(PNGImageFile(f))
开发者ID:torchbox,项目名称:Willow,代码行数:3,代码来源:test_pillow.py


示例9: TestPillowOperations

import unittest
import io
import imghdr

from PIL import Image as PILImage

from willow.image import JPEGImageFile, PNGImageFile, GIFImageFile, WebPImageFile
from willow.plugins.pillow import _PIL_Image, PillowImage, UnsupportedRotation


no_webp_support = not PillowImage.is_format_supported("WEBP")


class TestPillowOperations(unittest.TestCase):
    def setUp(self):
        with open('tests/images/transparent.png', 'rb') as f:
            self.image = PillowImage.open(PNGImageFile(f))

    def test_get_size(self):
        width, height = self.image.get_size()
        self.assertEqual(width, 200)
        self.assertEqual(height, 150)

    def test_resize(self):
        resized_image = self.image.resize((100, 75))
        self.assertEqual(resized_image.get_size(), (100, 75))

    def test_crop(self):
        cropped_image = self.image.crop((10, 10, 100, 100))
        self.assertEqual(cropped_image.get_size(), (90, 90))
开发者ID:torchbox,项目名称:Willow,代码行数:30,代码来源:test_pillow.py



注:本文中的willow.plugins.pillow.PillowImage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python lowlevel.add_event_receiver函数代码示例发布时间:2022-05-26
下一篇:
Python image.Image类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap