Python PIL 오기 또는 내보내기 프로세스의 경우 자르기

0

질문

나는 짧은 스크립트는 슬라이스 tiff 파일에 작은 조각합니다.

파일 크로 전형(가장 큰 파일은 16000x28800 픽셀 1 조금 깊이) Image with patches

내 생각,각각의 이 직사각형 및 저장을 이 새로운 파일과 동일한 해상도 원본 이미지


     from PIL import Image

     Image.MAX_IMAGE_PIXELS = None
     rows = 9
     cols = 5

     im = Image.open("Patches_TP_2540.tif")
     width, heigth = im.size
     res = 2540

     print(width, heigth)

     patchSize = int(width / cols)

     offset_x_tl = 0
     offset_y_tl = 0
     for r in range(rows):
        offset_y_tl = r * patchSize
        for c in range(cols):
           print(r, c)
           offset_x_tl = c * patchSize
           offset_y_br = offset_y_tl + patchSize
           offset_x_br = offset_x_tl + patchSize
           print(offset_x_tl, offset_y_tl, offset_x_br, offset_y_br)

           croped_area = im.crop((offset_x_tl, offset_y_tl, offset_x_br, offset_y_br))
           croped_area.save("Patch_"+ str(res) +"_" + str(r) + "_" + str(c) +".tiff", dpi=(2540,2540)) 
  


    print("Done!")

실행하는 경우 이 코드는 끝나지 않고 인쇄를 수행! 를 제거하는 경우 croped_area 및 저장을 명령한 코드는 실행하는 괜찮습니다. 새로운 이미지를 생성 및 저장 workds 한다.

나가도 등급을 사용하여 임시 이미지를 지키는 게 아니에요.복사(). 는 경우 내가 이것을 하고 있는 코드에서 정지 복사 과정입니다.

아마 사람이 나를 도울 수 있습니와 함께 이 문제는 약간의 트릭 문제를 해결하는 방법.

읽어 주셔서 감사합니다, Timo

Tiff Exiff 정보로 요청 마크 Setchell

ExiffTool Output
ExifTool Version Number         : 12.36
File Name                       : Patches_TP_2540.tif
Directory                       : .
File Size                       : 1967 KiB
File Modification Date/Time     : 2021:11:23 22:04:59+01:00
File Access Date/Time           : 2021:11:24 16:38:45+01:00
File Creation Date/Time         : 2021:11:23 22:04:58+01:00
File Permissions                : -rw-rw-rw-
File Type                       : TIFF
File Type Extension             : tif
MIME Type                       : image/tiff
Exif Byte Order                 : Little-endian (Intel, II)
Subfile Type                    : Full-resolution image
Image Width                     : 8000
Image Height                    : 14400
Bits Per Sample                 : 1
Compression                     : LZW
Photometric Interpretation      : WhiteIsZero
Strip Offsets                   : (Binary data 407 bytes, use -b option to extract)
Orientation                     : Horizontal (normal)
Samples Per Pixel               : 1
Rows Per Strip                  : 262
Strip Byte Counts               : (Binary data 329 bytes, use -b option to extract)
X Resolution                    : 2540
Y Resolution                    : 2540
Resolution Unit                 : inches
Software                        : Adobe Photoshop CS2 Windows
Modify Date                     : 2021:11:23 22:04:58
XMP Toolkit                     : 3.1.1-111
Format                          : image/tiff
Creator Tool                    : Adobe Photoshop CS2 Windows
Create Date                     : 2021:11:23 22:04:34+01:00
Metadata Date                   : 2021:11:23 22:04:58+01:00
Document ID                     : uuid:2A661B24A04CEC1180E9F8C3BA2D9028
Instance ID                     : uuid:2B661B24A04CEC1180E9F8C3BA2D9028
Native Digest                   : 256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;5F3D788B45930CC20D5D52E96A1450A4
Color Mode                      : Bitmap
History                         :
IPTC Digest                     : 00000000000000000000000000000000
Displayed Units X               : inches
Displayed Units Y               : inches
Print Style                     : Centered
Print Position                  : 0 0
Print Scale                     : 1
Global Angle                    : 120
Global Altitude                 : 30
Copyright Flag                  : False
URL List                        :
Slices Group Name               : Patches
Num Slices                      : 1
Pixel Aspect Ratio              : 1
Photoshop Thumbnail             : (Binary data 10944 bytes, use -b option to extract)
Has Real Merged Data            : Yes
Writer Name                     : Adobe Photoshop
Reader Name                     : Adobe Photoshop CS2
Color Space                     : Uncalibrated
Exif Image Width                : 8000
Exif Image Height               : 14400
Image Size                      : 8000x14400
Megapixels                      : 115.2

베개로 설치 프로그램에서 요청 마크 Setchell

Pillow 8.2.0
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)]
--------------------------------------------------------------------
Python modules loaded from C:\Users\timo\Anaconda3\envs\tensorflow\lib\site-packages\PIL
Binary modules loaded from C:\Users\timo\Anaconda3\envs\tensorflow\lib\site-packages\PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 8.2.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.10.4
*** LITTLECMS2 support not installed
*** WEBP support not installed
*** WEBP Transparency support not installed
*** WEBPMUX support not installed
*** WEBP Animation support not installed
--- JPEG support ok, compiled for 9.0
*** OPENJPEG (JPEG2000) support not installed
--- ZLIB (PNG/ZIP) support ok, loaded 1.2.11
--- LIBTIFF support ok, loaded 4.2.0
*** RAQM (Bidirectional Text) support not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
*** XCB (X protocol) support not installed
--------------------------------------------------------------------
BLP
Extensions: .blp
Features: open
--------------------------------------------------------------------
BMP image/bmp
Extensions: .bmp
Features: open, save
--------------------------------------------------------------------
BUFR
Extensions: .bufr
Features: open, save
--------------------------------------------------------------------
CUR
Extensions: .cur
Features: open
--------------------------------------------------------------------
DCX
Extensions: .dcx
Features: open
--------------------------------------------------------------------
DDS
Extensions: .dds
Features: open
--------------------------------------------------------------------
DIB image/bmp
Extensions: .dib
Features: open, save
--------------------------------------------------------------------
EPS application/postscript
Extensions: .eps, .ps
Features: open, save
--------------------------------------------------------------------
FITS
Extensions: .fit, .fits
Features: open, save
--------------------------------------------------------------------
FLI
Extensions: .flc, .fli
Features: open
--------------------------------------------------------------------
FPX
Extensions: .fpx
Features: open
--------------------------------------------------------------------
FTEX
Extensions: .ftc, .ftu
Features: open
--------------------------------------------------------------------
GBR
Extensions: .gbr
Features: open
--------------------------------------------------------------------
GIF image/gif
Extensions: .gif
Features: open, save, save_all
--------------------------------------------------------------------
GRIB
Extensions: .grib
Features: open, save
--------------------------------------------------------------------
HDF5
Extensions: .h5, .hdf
Features: open, save
--------------------------------------------------------------------
ICNS
Extensions: .icns
Features: open
--------------------------------------------------------------------
ICO image/x-icon
Extensions: .ico
Features: open, save
--------------------------------------------------------------------
IM
Extensions: .im
Features: open, save
--------------------------------------------------------------------
IMT
Features: open
--------------------------------------------------------------------
IPTC
Extensions: .iim
Features: open
--------------------------------------------------------------------
JPEG image/jpeg
Extensions: .jfif, .jpe, .jpeg, .jpg
Features: open, save
--------------------------------------------------------------------
JPEG2000 image/jp2
Extensions: .j2c, .j2k, .jp2, .jpc, .jpf, .jpx
Features: open, save
--------------------------------------------------------------------
MCIDAS
Features: open
--------------------------------------------------------------------
MIC
Extensions: .mic
Features: open
--------------------------------------------------------------------
MPEG video/mpeg
Extensions: .mpeg, .mpg
Features: open
--------------------------------------------------------------------
MSP
Extensions: .msp
Features: open, save, decode
--------------------------------------------------------------------
PCD
Extensions: .pcd
Features: open
--------------------------------------------------------------------
PCX image/x-pcx
Extensions: .pcx
Features: open, save
--------------------------------------------------------------------
PIXAR
Extensions: .pxr
Features: open
--------------------------------------------------------------------
PNG image/png
Extensions: .apng, .png
Features: open, save, save_all
--------------------------------------------------------------------
PPM image/x-portable-anymap
Extensions: .pbm, .pgm, .pnm, .ppm
Features: open, save
--------------------------------------------------------------------
PSD image/vnd.adobe.photoshop
Extensions: .psd
Features: open
--------------------------------------------------------------------
SGI image/sgi
Extensions: .bw, .rgb, .rgba, .sgi
Features: open, save
--------------------------------------------------------------------
SPIDER
Features: open, save
--------------------------------------------------------------------
SUN
Extensions: .ras
Features: open
--------------------------------------------------------------------
TGA image/x-tga
Extensions: .icb, .tga, .vda, .vst
Features: open, save
--------------------------------------------------------------------
TIFF image/tiff
Extensions: .tif, .tiff
Features: open, save, save_all
--------------------------------------------------------------------
WEBP
Features: open
--------------------------------------------------------------------
WMF
Extensions: .emf, .wmf
Features: open, save
--------------------------------------------------------------------
XBM image/xbm
Extensions: .xbm
Features: open, save
--------------------------------------------------------------------
XPM image/xpm
Extensions: .xpm
Features: open
--------------------------------------------------------------------
XVTHUMB
Features: open
--------------------------------------------------------------------
crop python python-imaging-library tiff
2021-11-23 21:34:17
2

최고의 응답

0

그 솔기 PIL 고 작물은 몇 가지 문제가 LZW 압축합니다. 을 제거하는 압축 포토샵으로 만든 스크립트를 실행하는 다음과 같이 예상된다.

2021-11-24 16:25:20
0

당신의 아이디어 bouding 자 영역으로 이용할 수 있는 방법을 작물 이미지

from PIL import Image
img = Image.open("imagefile")

#도약을 위한 지역 예

#왼쪽=90,top=580,오른쪽=1600,아래=2000

img_res = img.crop((left, top, right, bottom))
with open(outfile4, 'w') as f:
    img_res.save(outfile_path,'JPEG')
2021-11-24 16:43:00

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................