Reads image data from the file named FILENAME into the image. The FORMAT option specifies the format of the image data in the file. The FROM_COORDS option specifies a rectangular sub-region of the image file data to be copied to the destination image. It must be a
(self, filename, format=None, *, from_coords=None, to=None, shrink=False)
| 4421 | self.tk.call(args) |
| 4422 | |
| 4423 | def read(self, filename, format=None, *, from_coords=None, to=None, shrink=False): |
| 4424 | """Reads image data from the file named FILENAME into the image. |
| 4425 | |
| 4426 | The FORMAT option specifies the format of the image data in the |
| 4427 | file. |
| 4428 | |
| 4429 | The FROM_COORDS option specifies a rectangular sub-region of the image |
| 4430 | file data to be copied to the destination image. It must be a tuple |
| 4431 | or a list of 1 to 4 integers (x1, y1, x2, y2). (x1, y1) and |
| 4432 | (x2, y2) specify diagonally opposite corners of the rectangle. If |
| 4433 | x2 and y2 are not specified, the default value is the bottom-right |
| 4434 | corner of the source image. The default, if this option is not |
| 4435 | specified, is the whole of the image in the image file. |
| 4436 | |
| 4437 | The TO option specifies the coordinates of the top-left corner of |
| 4438 | the region of the image into which data from filename are to be |
| 4439 | read. The default is (0, 0). |
| 4440 | |
| 4441 | If SHRINK is true, the size of the destination image will be |
| 4442 | reduced, if necessary, so that the region into which the image file |
| 4443 | data are read is at the bottom-right corner of the image. |
| 4444 | """ |
| 4445 | options = () |
| 4446 | if format is not None: |
| 4447 | options += ('-format', format) |
| 4448 | if from_coords is not None: |
| 4449 | options += ('-from', *from_coords) |
| 4450 | if shrink: |
| 4451 | options += ('-shrink',) |
| 4452 | if to is not None: |
| 4453 | options += ('-to', *to) |
| 4454 | self.tk.call(self.name, 'read', filename, *options) |
| 4455 | |
| 4456 | def write(self, filename, format=None, from_coords=None, *, |
| 4457 | background=None, grayscale=False): |