README.md

# ai-minecraft-image

A lightweight Elixir library for converting images into Minecraft skin formats. This package provides tools for processing and transforming images to be compatible with Minecraft skin requirements.

## Installation

Add `ai_minecraft_image` to your list of dependencies in `mix.exs`:
elixir
def deps do
  [
    {:ai_minecraft_image, "~> 0.1.0"}
  ]
end

After adding the dependency, run:
bash
mix deps.get

## Usage Examples

The `AiMinecraftImage` module provides functions for image manipulation and conversion. Here are a few examples demonstrating common use cases:

**1. Basic Image Conversion:**
elixir
image_path = "path/to/your/image.png"

case AiMinecraftImage.convert_to_skin(image_path) do
  {:ok, skin_data} ->
    File.write!("skin.png", skin_data)
    IO.puts "Skin conversion successful! Saved to skin.png"
  {:error, reason} ->
    IO.puts "Error converting image: #{reason}"
end

**2. Handling Different Image Types:**
elixir
defmodule ImageProcessor do
  def process_image(image_path) do
    case AiMinecraftImage.convert_to_skin(image_path) do
      {:ok, skin_data} -> {:ok, skin_data}
      {:error, reason} -> {:error, reason}
    end
  end
end

image_path = "path/to/your/image.jpg"

case ImageProcessor.process_image(image_path) do
  {:ok, skin_data} ->
    # Further processing of skin_data
    IO.puts "Image processed successfully."
  {:error, reason} ->
    IO.puts "Error processing image: #{reason}"
end

**3. Using Pipes for Image Processing:**
elixir
image_path = "path/to/your/image.bmp"

image_path
|> AiMinecraftImage.convert_to_skin()
|> case do
  {:ok, skin_data} ->
    File.write!("skin.png", skin_data)
    IO.puts "Skin conversion successful using pipes!"
  {:error, reason} ->
    IO.puts "Error converting image using pipes: #{reason}"
end

**4. Resizing and Converting:**

While this library primarily focuses on format conversion, future extensions might incorporate resizing.  For now, it's recommended to pre-process your image to the desired Minecraft skin dimensions (64x64 pixels) using an external image processing library or tool.
elixir
# Example (Conceptual - Requires external image library like ImageMagick)
# This is for illustration ONLY.  The ai-minecraft-image package does not directly resize images.

# {:ok, resized_image} = ImageMagick.resize("path/to/large_image.png", 64, 64)
# case AiMinecraftImage.convert_to_skin(resized_image) do
#   {:ok, skin_data} -> ...
# end

**5. Error Handling and Logging:**
elixir
image_path = "invalid/image/path.txt"

case AiMinecraftImage.convert_to_skin(image_path) do
  {:ok, _} ->
    # This should not happen
    IO.puts "Unexpected success with invalid path!"

  {:error, :file_not_found} ->
    Logger.warn "Image file not found: #{image_path}"

  {:error, reason} ->
    Logger.error "Error during conversion: #{reason}"
end

## Feature Summary

*   Converts standard image formats (PNG, JPG, BMP) to a Minecraft skin-compatible PNG format.
*   Provides a simple and clean Elixir API.
*   Includes robust error handling for common issues like file not found or invalid image data.
*   Focuses on the core conversion process, allowing for easy integration with other image processing pipelines.

## License

MIT

This package is part of the ai-minecraft-image ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/image/blog/how-to_turn_your_image_into_minecraft_skin/