1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      Python切圖九宮格的實現(xiàn)方法-創(chuàng)新互聯(lián)

      創(chuàng)新互聯(lián)主要從事成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)烏審,10余年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792
      # -*- coding: utf-8 -*-
      '''
      將一張圖片填充為正方形后切為9張圖
      '''
      from PIL import Image
      import sys
      #將圖片填充為正方形
      def fill_image(image):
        width, height = image.size
        #選取長和寬中較大值作為新圖片的
        new_image_length = width if width > height else height
        #生成新圖片[白底]
        new_image = Image.new(image.mode, (new_image_length, new_image_length), color='white')
        #將之前的圖粘貼在新圖上,居中
        if width > height:#原圖寬大于高,則填充圖片的豎直維度
          #(x,y)二元組表示粘貼上圖相對下圖的起始位置
          new_image.paste(image, (0, int((new_image_length - height) / 2)))
        else:
          new_image.paste(image, (int((new_image_length - width) / 2),0))
        return new_image
      #切圖
      def cut_image(image):
        width, height = image.size
        item_width = int(width / 3)
        box_list = []
        # (left, upper, right, lower)
        for i in range(0,3):#兩重循環(huán),生成9張圖片基于原圖的位置
          for j in range(0,3):
            #print((i*item_width,j*item_width,(i+1)*item_width,(j+1)*item_width))
            box = (j*item_width,i*item_width,(j+1)*item_width,(i+1)*item_width)
            box_list.append(box)
      
        image_list = [image.crop(box) for box in box_list]
        return image_list
      #保存
      def save_images(image_list):
        index = 1
        for image in image_list:
          image.save('./python'+str(index) + '.png', 'PNG')
          index += 1
      
      if __name__ == '__main__':
        file_path = "python.jpeg"
        image = Image.open(file_path)
        #image.show()
        image = fill_image(image)
        image_list = cut_image(image)
        save_images(image_list)

      當(dāng)前名稱:Python切圖九宮格的實現(xiàn)方法-創(chuàng)新互聯(lián)
      新聞來源:http://ef60e0e.cn/article/codejg.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        顺平县| 玛纳斯县| 县级市| SHOW| 房产| 扬中市| 石嘴山市| 上林县| 曲沃县| 贵溪市| 巴林右旗| 潼南县| 通州区| 满城县| 乌鲁木齐县| 封开县| 九寨沟县| 云梦县| 广东省| 宣武区| 鄂尔多斯市| 乌苏市| 红桥区| 泸定县| 德昌县| 瑞金市| 灵丘县| 句容市| 凤阳县| 高邮市| 罗甸县| 连州市| 同德县| 林州市| 寿光市| 吴忠市| 景洪市| 通山县| 秀山| 桐乡市| 通州区|