# Vision utils


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

------------------------------------------------------------------------

<a
href="https://github.com/fastai/fastai/blob/main/fastai/vision/utils.py#L38"
target="_blank" style="float:right; font-size:smaller">source</a>

### download_images

``` python

def download_images(
    dest, url_file:NoneType=None, urls:NoneType=None, max_pics:int=1000, n_workers:int=8, timeout:int=4,
    preserve_filename:bool=False
):

```

*Download images listed in text file `url_file` to path `dest`, at most
`max_pics`*

------------------------------------------------------------------------

<a
href="https://github.com/fastai/fastai/blob/main/fastai/vision/utils.py#L47"
target="_blank" style="float:right; font-size:smaller">source</a>

### resize_to

``` python

def resize_to(
    img, targ_sz, use_min:bool=False
):

```

*Size to resize to, to hit `targ_sz` at same aspect ratio, in PIL coords
(i.e w*h)\*

``` python
class _FakeImg():
    def __init__(self, size): self.size=size

img = _FakeImg((200,500))
test_eq(resize_to(img, 400), [160,400])
test_eq(resize_to(img, 400, use_min=True), [400,1000])
```

------------------------------------------------------------------------

<a
href="https://github.com/fastai/fastai/blob/main/fastai/vision/utils.py#L55"
target="_blank" style="float:right; font-size:smaller">source</a>

### verify_image

``` python

def verify_image(
    fn
):

```

*Confirm that `fn` can be opened*

------------------------------------------------------------------------

<a
href="https://github.com/fastai/fastai/blob/main/fastai/vision/utils.py#L65"
target="_blank" style="float:right; font-size:smaller">source</a>

### verify_images

``` python

def verify_images(
    fns
):

```

*Find images in `fns` that can’t be opened*

------------------------------------------------------------------------

<a
href="https://github.com/fastai/fastai/blob/main/fastai/vision/utils.py#L70"
target="_blank" style="float:right; font-size:smaller">source</a>

### resize_image

``` python

def resize_image(
    file, dest, src:str='.', max_size:NoneType=None, n_channels:int=3, ext:NoneType=None, img_format:NoneType=None,
    resample:Resampling=<Resampling.BILINEAR: 2>, resume:bool=False, kwargs:VAR_KEYWORD
):

```

*Resize file to dest to max_size*

``` python
file = 'puppy.jpg'
dest = Path('.')
resize_image(file, dest, src='images', max_size=400)
im = Image.open(dest/file)
test_eq(im.shape[1],400)
(dest/file).unlink()
```

``` python
file = 'puppy.jpg'
dest = Path('images')
resize_image(file, dest, src=dest, max_size=None)
```

------------------------------------------------------------------------

<a
href="https://github.com/fastai/fastai/blob/main/fastai/vision/utils.py#L94"
target="_blank" style="float:right; font-size:smaller">source</a>

### resize_images

``` python

def resize_images(
    path, max_workers:int=4, max_size:NoneType=None, recurse:bool=False, dest:PosixPath=Path('.'), n_channels:int=3,
    ext:NoneType=None, img_format:NoneType=None, resample:Resampling=<Resampling.BILINEAR: 2>, resume:NoneType=None,
    kwargs:VAR_KEYWORD
):

```

*Resize files on path recursively to dest to max_size*

``` python
with tempfile.TemporaryDirectory() as d:
    dest = Path(d)/'resized_images'
    resize_images('images', max_size=100, dest=dest, max_workers=0, recurse=True)
```
