### Constructor

# Vips Image thumbnail

#### Declaration [src]

    int
    vips_thumbnail (
      const char* filename,
      VipsImage** out,
      int width,
      ...
    )

#### Description [src]

Make a thumbnail from a file.

Shrinking is done in three stages: using any shrink-on-load features available in the image load library, using a block shrink, and using a lanczos3 shrink. At least the final 200% is done with lanczos3. The output should be high quality, and the operation should be quick.

See `vips_thumbnail_buffer()` to thumbnail from a memory buffer, or `vips_thumbnail_source()` to thumbnail from an arbitrary byte source.

By default, libvips will only use the first frame of animated or multipage images. To thumbnail all pages or frames, pass `n=-1` to the loader in `filename`, for example `"x.gif[n=-1]"`.

The output image will fit within a square of size `width` x `width`. You can specify a separate height with the `height` option. Set either `width` or `height` to a very large number to ignore that dimension.

If you set `crop`, then the output image will fill the whole of the `width` x `height` rectangle, with any excess cropped away. See `vips_smartcrop()` for details on the cropping strategy.

Normally the operation will upsize or downsize as required to fit the image inside or outside the target size. If `size` is set to `VIPS_SIZE_UP`, the operation will only upsize and will just copy if asked to downsize. If `size` is set to `VIPS_SIZE_DOWN`, the operation will only downsize and will just copy if asked to upsize. If `size` is `VIPS_SIZE_FORCE`, the image aspect ratio will be broken and the image will be forced to fit the target.

Normally any orientation tags on the input image (such as EXIF tags) are interpreted to rotate the image upright. If you set `no_rotate` to `TRUE`, these tags will not be interpreted.

Shrinking is normally done in sRGB colourspace. Set `linear` to shrink in linear light colourspace instead. This can give better results, but can also be far slower, since tricks like JPEG shrink-on-load cannot be used in linear space.

If you set `output_profile` to the filename of an ICC profile, the image will be transformed to the target colourspace before writing to the output. You can also give an `input_profile` which will be used if the input image has no ICC profile, or if the profile embedded in the input image is broken.

Use `intent` to set the rendering intent for any ICC transform. The default is `VIPS_INTENT_RELATIVE`.

Use `fail_on` to control the types of error that will cause loading to fail. The default is `VIPS_FAIL_ON_NONE`, ie. thumbnail is permissive.

Optional arguments

- `height`: `gint`, target height in pixels
- `size`: `VipsSize`, upsize, downsize, both or force
- `no_rotate`: `gboolean`, don’t rotate upright using orientation tag
- `crop`: `VipsInteresting`, shrink and crop to fill target
- `linear`: `gboolean`, perform shrink in linear light
- `input_profile`: `gchararray`, fallback input ICC profile
- `output_profile`: `gchararray`, output ICC profile
- `intent`: `VipsIntent`, rendering intent
- `fail_on`: `VipsFailOn`, load error types to fail on

See also

`vips_thumbnail_buffer()`.

This constructor is not directly available to language bindings.

#### Parameters

`filename`

  Type: `const char*`

  File to read from.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`out`

  Type: `VipsImage`

  Output image.

  The argument will be set by the function.
  The caller of the function takes ownership of the returned data, and is responsible for freeing it.

`width`

  Type: `int`

  Target width in pixels.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.