nano-banana

A lightweight Elixir library for efficient image processing and manipulation tasks. Simplifies common image operations with a focus on ease of use and performance.

Installation

To install nano-banana, add it as a dependency to your mix.exs file: elixir def deps do [

{:nano_banana, "~> 0.1.0"} # Replace with the actual version

] end

Then, run mix deps.get to fetch and install the dependency.

Usage Examples

Here are a few examples demonstrating how to use nano-banana for common image processing tasks:

1. Resizing an Image: elixir alias NanoBanana.Image

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

case Image.resize(imagepath, output_path, width: 200, height: 150) do {:ok, } ->

IO.puts("Image resized successfully!")

->

IO.puts("Error resizing image: #{reason}")

end

2. Converting Image Format: elixir alias NanoBanana.Image

image_path = "path/to/your/image.png" output_path = "path/to/converted_image.jpg"

case Image.convert(imagepath, output_path, format: :jpeg) do {:ok, } ->

IO.puts("Image converted successfully!")

->

IO.puts("Error converting image: #{reason}")

end

3. Applying a Grayscale Filter: elixir alias NanoBanana.Image

image_path = "path/to/your/image.bmp" output_path = "path/to/grayscale_image.bmp"

case Image.grayscale(imagepath, output_path) do {:ok, } ->

IO.puts("Grayscale filter applied successfully!")

->

IO.puts("Error applying grayscale filter: #{reason}")

end

4. Cropping an Image: elixir alias NanoBanana.Image

image_path = "path/to/your/image.tiff" output_path = "path/to/cropped_image.tiff"

case Image.crop(imagepath, output_path, x: 50, y: 50, width: 100, height: 100) do {:ok, } ->

IO.puts("Image cropped successfully!")

->

IO.puts("Error cropping image: #{reason}")

end

5. Using the Pipe Operator for Multiple Operations: elixir alias NanoBanana.Image

image_path = "path/to/your/image.gif" output_path = "path/to/processed_image.png"

imagepath |> Image.resize(output_path, width: 300, height: 200) |> then(fn {:ok, } -> Image.grayscale(outputpath, output_path) {:error, reason} -> {:error, reason} end) |> then(fn {:ok, } -> IO.puts("Image resized and converted to grayscale successfully!") {:error, reason} -> IO.puts("Error processing image: #{reason}") end)

Feature Summary

License

MIT License

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