# `PhoenixKit.Modules.Storage.ImageProcessor`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.165/lib/modules/storage/services/image_processor.ex#L1)

ImageMagick-based image processing module.

Handles image operations using ImageMagick command-line tools:
- `identify` - Extract image metadata (dimensions, format)
- `convert`/`magick` - Resize and format conversion

This replaces Vix with ImageMagick, which is more widely trusted
and has better long-term support.

# `extract_dimensions`

Extract both width and height from an image file.

Uses ImageMagick's `identify` command to extract image dimensions.

Returns:
- `{:ok, {width, height}}` - Dimensions in pixels
- `{:error, reason}` - If extraction fails

# `get_height`

Get the height of an image file using ImageMagick identify.

Returns the height in pixels or nil if extraction fails.

# `get_width`

Get the width of an image file using ImageMagick identify.

Returns the width in pixels or nil if extraction fails.

# `resize`

Resize an image to fit within specified dimensions.

Maintains aspect ratio by scaling to fit within bounds.
Optionally converts format based on output_format parameter.

Parameters:
- `input_path` - Path to input image file
- `output_path` - Path to save resized image
- `width` - Target width (nil to use original)
- `height` - Target height (nil to use original)
- `opts` - Additional options
  - `:quality` - JPEG quality 1-100 (default: 85)
  - `:format` - Output format override (jpg, png, webp, etc)

Returns:
- `{:ok, output_path}` - Success
- `{:error, reason}` - If resize fails

# `resize_and_crop_center`

Resize and center-crop an image to exact dimensions.

Zooms into the image to fill the target dimensions completely, then
center-crops to extract the exact target size. No padding borders - the
entire output is filled with the image content.

This is ideal for thumbnails where you want perfect squares (e.g., 150x150)
with the image zoomed in and centered, no white/black borders.

The algorithm:
1. Resizes image to fill the target box (scales to cover both dimensions)
2. Centers the image using gravity
3. Crops from center to exact target dimensions

Parameters:
- `input_path` - Path to input image file
- `output_path` - Path to save cropped image
- `width` - Target width (required)
- `height` - Target height (required)
- `opts` - Additional options
  - `:quality` - JPEG quality 1-100 (default: 85)
  - `:format` - Output format override (jpg, png, webp, etc)
  - `:background` - Background color (rarely used, default: "white")

Returns:
- `{:ok, output_path}` - Success
- `{:error, reason}` - If processing fails

---

*Consult [api-reference.md](api-reference.md) for complete listing*
