Table of Contents

## Name

im_jpeg2vips, im_vips2jpeg, im_vips2bufjpeg, im_vips2mimejpeg - convert JPEG images to and from VIPS format

## Synopsis

#include <vips/vips.h>

int im_jpeg2vips( char *filename, IMAGE *out )

int im_jpeg2vips_header( char *filename, IMAGE *out )

int im_vips2jpeg( IMAGE *in, char *filename )

int im_vips2bufjpeg( IMAGE *in, IMAGE *base, char **obuf, int *olen )

int im_vips2mimejpeg( IMAGE *in )

## Description

im_jpeg2vips() reads the named jpeg file and writes it to the specified IMAGE. The entire image is read before returning. It will handle 1 and 3 band 8-bit images only.

Any embedded ICC profiles are ignored: you always just the the RGB from the file.

im_jpeg2vips_header() reads just the header of the JPEG file, and sets the fields in the VIPS image. You can't read any pixels! This is only useful for printing header information.

im_vips2jpeg() writes the IMAGE to filename in JPEG format. It uses the default settings of the IJG library.

A compression factor may be encoded in the filename: for example, "fred.jpg" will write with the default compression factor (75), "fred.jpg:25" will write with factor 25.

An ICC profile may also be specified. For example, "fred.jpg:25,/home/john/srgb.icc" will embed the profile stored in the file "/home/john/srgb.icc" into the JPEG image. This does not affect the pixels which are written, just the way they are tagged. Very few image readers respect this tag.

im_vips2bufjpeg() returns the compressed image in a memory buffer. The buffer is allocated for you, local to IMAGE descriptor base. The size of the allocated buffer is returned in the olen parameter. You are responsible for freeing the buffer. The buffer is only allocated if the function returns successfully.

im_vips2mimejpeg() writes the image to stdout as a MIME image/jpeg type. It outputs Content-Length and Content-Type fields making the result suitable for a web browser.

## See Also

im_isjpeg(3) .

Table of Contents

- Name
- Synopsis
- Description
- See Also