| Exiv2

Loading...
Searching...
No Matches
Static Public Member Functions | Friends | List of all members
Exiv2::ImageFactory Class Reference

Returns an Image instance of the specified type. More...

`#include <image.hpp>`

## Static Public Member Functions
static BasicIo::UniquePtr | createIo (const std::string &path, bool useCurl=true)
| Create the appropriate class type implemented BasicIo based on the protocol of the input.
static Image::UniquePtr | open (const std::string &path, bool useCurl=true)
| Create an Image subclass of the appropriate type by reading the specified file. Image type is derived from the file contents.
static Image::UniquePtr | open (const byte *data, size_t size)
| Create an Image subclass of the appropriate type by reading the provided memory. Image type is derived from the memory contents.
static Image::UniquePtr | open (BasicIo::UniquePtr io)
| Create an Image subclass of the appropriate type by reading the provided BasicIo instance. Image type is derived from the data provided by io. The passed in io instance is (re)opened by this method.
static Image::UniquePtr | create (ImageType type, const std::string &path)
| Create an Image subclass of the requested type by creating a new image file. If the file already exists, it will be overwritten.
static Image::UniquePtr | create (ImageType type)
| Create an Image subclass of the requested type by creating a new image in memory.
static Image::UniquePtr | create (ImageType type, BasicIo::UniquePtr io)
| Create an Image subclass of the requested type by writing a new image to a BasicIo instance. If the BasicIo instance already contains data, it will be overwritten.
static ImageType | getType (const std::string &path)
| Returns the image type of the provided file.
static ImageType | getType (const byte *data, size_t size)
| Returns the image type of the provided data buffer.
static ImageType | getType (BasicIo &io)
| Returns the image type of data provided by a BasicIo instance. The passed in io instance is (re)opened by this method.
static AccessMode | checkMode (ImageType type, MetadataId metadataId)
| Returns the access mode or supported metadata functions for an image type and a metadata type.
static bool | checkType (ImageType type, BasicIo &io, bool advance)
| Determine if the content of io is an image of type.

## Friends
bool | Image::good () const

## Detailed Description

Returns an Image instance of the specified type.

The factory is implemented as a static class.

## Member Function Documentation

## ◆ checkMode()

AccessMode Exiv2::ImageFactory::checkMode | ( | ImageType | type,
|  | MetadataId | metadataId )
| static

Returns the access mode or supported metadata functions for an image type and a metadata type.

Parameters

  type | The image type.
  metadataId | The metadata identifier.

Returns
  Access mode for the requested image type and metadata identifier.

Exceptions

  Error(kerUnsupportedImageType) | if the image type is not supported.

References Exiv2::find().

Referenced by Exiv2::Image::checkMode().

## ◆ checkType()

bool Exiv2::ImageFactory::checkType | ( | ImageType | type,
|  | BasicIo & | io,
|  | bool | advance )
| static

Determine if the content of io is an image of type.

The advance flag determines if the read position in the stream is moved (see below). This applies only if the type matches and the function returns true. If the type does not match, the stream position is not changed. However, if reading from the stream fails, the stream position is undefined. Consult the stream state to obtain more information in this case.

Parameters

  type | Type of the image.
  io | BasicIo instance to read from.
  advance | Flag indicating whether the position of the io should be advanced by the number of characters read to analyse the data (true) or left at its original position (false). This applies only if the type matches.

Returns
  true if the data matches the type of this class;
  false if the data does not match

References Exiv2::find().

Referenced by Exiv2::Image::good().

## ◆ create() [1/3]

Image::UniquePtr Exiv2::ImageFactory::create | ( | ImageType | type | ) |
| static

Create an Image subclass of the requested type by creating a new image in memory.

Parameters

  type | Type of the image to be created.

Returns
  An auto-pointer that owns an Image instance of the requested type.

Exceptions

  Error | If the image type is not supported

References create().

## ◆ create() [2/3]

Image::UniquePtr Exiv2::ImageFactory::create | ( | ImageType | type,
|  | BasicIo::UniquePtr | io )
| static

Create an Image subclass of the requested type by writing a new image to a BasicIo instance. If the BasicIo instance already contains data, it will be overwritten.

Parameters

  type | Type of the image to be created.
  io | An auto-pointer that owns a BasicIo instance that will be written to when creating a new image.

Note
  This method takes ownership of the passed in BasicIo instance through the auto-pointer. Callers should not continue to use the BasicIo instance after it is passed to this method. Use the Image::io() method to get a temporary reference.

Returns
  An auto-pointer that owns an Image instance of the requested type. If the image type is not supported, the pointer is 0.

References Exiv2::find().

## ◆ create() [3/3]

Image::UniquePtr Exiv2::ImageFactory::create | ( | ImageType | type,
|  | const std::string & | path )
| static

Create an Image subclass of the requested type by creating a new image file. If the file already exists, it will be overwritten.

Parameters

  type | Type of the image to be created.
  path | Image file to create. File extension is ignored.

Returns
  An auto-pointer that owns an Image instance of the requested type.

Exceptions

  Error | If the image type is not supported.

References create(), and Exiv2::strError().

Referenced by create(), and create().

## ◆ createIo()

BasicIo::UniquePtr Exiv2::ImageFactory::createIo | ( | const std::string & | path,
|  | bool | useCurl = true )
| static

Create the appropriate class type implemented BasicIo based on the protocol of the input.

"-" path implies the data from stdin and it is handled by StdinIo. Http path can be handled by either HttpIo or CurlIo. Https, ftp paths are handled by CurlIo. Ssh, sftp paths are handled by SshIo. Others are handled by FileIo.

Parameters

  path | Image file.
  useCurl | Indicate whether the libcurl is used or not. If it's true, http is handled by CurlIo. Otherwise it is handled by HttpIo.

Returns
  An auto-pointer that owns an BasicIo instance.

Exceptions

  Error | If the file is not found or it is unable to connect to the server to read the remote file.

References Exiv2::fileProtocol().

Referenced by open().

## ◆ getType() [1/3]

ImageType Exiv2::ImageFactory::getType | ( | BasicIo & | io | ) |
| static

Returns the image type of data provided by a BasicIo instance. The passed in io instance is (re)opened by this method.

Parameters

  io | A BasicIo instance that provides image data. The contents of the image data are tested to determine the type.

Returns
  Image type or Image::none if the type is not recognized.

References Exiv2::BasicIo::open().

## ◆ getType() [2/3]

ImageType Exiv2::ImageFactory::getType | ( | const byte * | data,
|  | size_t | size )
| static

Returns the image type of the provided data buffer.

Parameters

  data | Pointer to a data buffer containing an image. The contents of the memory are tested to determine the image type.
  size | Number of bytes pointed to by data.

Returns
  Image type or Image::none if the type is not recognized.

References Exiv2::getType().

## ◆ getType() [3/3]

ImageType Exiv2::ImageFactory::getType | ( | const std::string & | path | ) |
| static

Returns the image type of the provided file.

Parameters

  path | Image file. The contents of the file are tested to determine the image type. File extension is ignored.

Returns
  Image type or Image::none if the type is not recognized.

References Exiv2::getType().

## ◆ open() [1/3]

Image::UniquePtr Exiv2::ImageFactory::open | ( | BasicIo::UniquePtr | io | ) |
| static

Create an Image subclass of the appropriate type by reading the provided BasicIo instance. Image type is derived from the data provided by io. The passed in io instance is (re)opened by this method.

Parameters

  io | An auto-pointer that owns a BasicIo instance that provides image data. The contents of the image data are tested to determine the type.

Note
  This method takes ownership of the passed in BasicIo instance through the auto-pointer. Callers should not continue to use the BasicIo instance after it is passed to this method. Use the Image::io() method to get a temporary reference.

Returns
  An auto-pointer that owns an Image instance whose type matches that of the io data. If no image type could be determined, the pointer is 0.

Exceptions

  Error | If opening the BasicIo fails

References Exiv2::BasicIo::open(), Exiv2::BasicIo::path(), and Exiv2::strError().

## ◆ open() [2/3]

Image::UniquePtr Exiv2::ImageFactory::open | ( | const byte * | data,
|  | size_t | size )
| static

Create an Image subclass of the appropriate type by reading the provided memory. Image type is derived from the memory contents.

Parameters

  data | Pointer to a data buffer containing an image. The contents of the memory are tested to determine the image type.
  size | Number of bytes pointed to by data.

Returns
  An auto-pointer that owns an Image instance whose type matches that of the data buffer.

Exceptions

  Error | If the memory contains data of an unknown image type.

References open().

## ◆ open() [3/3]

Image::UniquePtr Exiv2::ImageFactory::open | ( | const std::string & | path,
|  | bool | useCurl = true )
| static

Create an Image subclass of the appropriate type by reading the specified file. Image type is derived from the file contents.

Parameters

  path | Image file. The contents of the file are tested to determine the image type. File extension is ignored.
  useCurl | Indicate whether the libcurl is used or not. If it's true, http is handled by CurlIo. Otherwise it is handled by HttpIo.

Returns
  An auto-pointer that owns an Image instance whose type matches that of the file.

Exceptions

  Error | If opening the file fails or it contains data of an unknown image type.

Examples
  addmoddel.cpp, exifcomment.cpp, exifdata.cpp, exifprint.cpp, exifvalue.cpp, geotag.cpp, iptceasy.cpp, iptcprint.cpp, metacopy.cpp, mrwthumb.cpp, and xmpprint.cpp.

References createIo(), and open().

Referenced by open(), open(), Exiv2::PgfImage::readMetadata(), and Exiv2::Rw2Image::readMetadata().

The documentation for this class was generated from the following files:

- image.hpp
- image.cpp