# Image Format Conversion

## ❗Make sure you import the library as the following

```python
from imageconvert import ImageConvert
```

The `ImageConvert` class provides static methods for converting images, batch processing directories, and retrieving image metadata.

***

## 📥 `convert()`

```python
ImageConvert.convert(input_path, output_path, quality=95, dpi=None, preserve_metadata=True, preserve_timestamps=True)
```

#### Description

Convert a single image to another format while preserving metadata and file timestamps.

#### Parameters

| Name                               | Type  | Description                                                     |
| ---------------------------------- | ----- | --------------------------------------------------------------- |
| `input_path`                       | str   | Path                                                            |
| `output_path`                      | str   | Path                                                            |
| `quality` *(optional)*             | int   | Quality for lossy formats (1–100). Default: `95`                |
| `dpi` *(optional)*                 | tuple | None                                                            |
| `preserve_metadata` *(optional)*   | bool  | Preserve EXIF and metadata. Default: `True`                     |
| `preserve_timestamps` *(optional)* | bool  | Preserve file creation/modification timestamps. Default: `True` |

#### Returns

`str`: Path to the converted image.

#### Raises

* `FileNotFoundError`
* `ValueError`
* `RuntimeError`
* `NotImplementedError`

#### Example

```python
ImageConvert.convert("image.jpg", "image.webp")
```

***

## 📂 `batch_convert()`

```python
ImageConvert.batch_convert(input_dir, output_dir, output_format=None, recursive=False, quality=95, preserve_metadata=True, preserve_timestamps=True, skip_existing=True)
```

#### Description

Batch convert all images in a folder to a specified format.

#### Parameters

| Name                               | Type | Description                                      |
| ---------------------------------- | ---- | ------------------------------------------------ |
| `input_dir`                        | str  | Path                                             |
| `output_dir`                       | str  | Path                                             |
| `output_format` *(optional)*       | str  | None                                             |
| `recursive` *(optional)*           | bool | Search subdirectories. Default: `False`          |
| `quality` *(optional)*             | int  | Quality for lossy formats. Default: `95`         |
| `preserve_metadata` *(optional)*   | bool | Preserve EXIF/metadata. Default: `True`          |
| `preserve_timestamps` *(optional)* | bool | Preserve timestamps. Default: `True`             |
| `skip_existing` *(optional)*       | bool | Skip files if already converted. Default: `True` |

#### Returns

`List[str]`: Paths to all successfully converted files.

#### Example

```python
ImageConvert.batch_convert("input/", "output/", output_format=".png", recursive=True)
```

***

## 🔍 `get_image_info()`

```python
ImageConvert.get_image_info(image_path)
```

#### Description

Get detailed metadata and properties of an image.

#### Parameters

| Name         | Type | Description |
| ------------ | ---- | ----------- |
| `image_path` | str  | Path        |

#### Returns

`Dict[str, Any]` with keys like:

* `filename`, `path`
* `width`, `height`, `format`, `mode`
* `timestamps`: `created`, `modified`, `accessed`
* `camera`: `{make, model, exposure_time, f_number, iso}`
* `gps`: `{latitude, longitude, altitude}`
* `exif_raw`, `raw_metadata`

#### Example

```python
info = ImageConvert.get_image_info("photo.jpg")
print(info["camera"])
```

***

## ✅ `is_supported_format()`

```python
ImageConvert.is_supported_format(filename)
```

#### Description

Check whether the given filename extension is supported.

#### Parameters

| Name       | Type | Description          |
| ---------- | ---- | -------------------- |
| `filename` | str  | Name or path to file |

#### Returns

`bool`: `True` if the format is supported, otherwise `False`.

***

## 🧩 `get_extension()`

```python
ImageConvert.get_extension(filename)
```

#### Description

Extract the file extension from a filename or path.

#### Parameters

| Name       | Type | Description           |
| ---------- | ---- | --------------------- |
| `filename` | str  | File path or filename |

#### Returns

`str`: File extension including the dot, in lowercase (e.g., `.jpg`)
