nano-banana-2-ai

A lightweight Elixir library for seamless image manipulation and AI-powered transformations, designed for integration with the NanaIMG platform. This package simplifies common image processing tasks within your Elixir applications.

Installation

To install nano-banana-2-ai, add it to your mix.exs dependencies: elixir def deps do [

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

] end

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

Usage Examples

Here are some examples demonstrating common use cases for nano-banana-2-ai:

1. Image Resizing: elixir alias NanoBanana2Ai.Image

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

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

IO.puts "Image resized successfully!"

->

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

end

2. Applying AI-Powered Filters: elixir alias NanoBanana2Ai.AI

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

case AI.apply_filter(image_path, output_path, filter: :enhance) do {:ok, _result} ->

IO.puts "Filter applied successfully!"

->

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

end

3. Converting Image Format: elixir alias NanoBanana2Ai.Image

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

case Image.convert_format(image_path, output_path, format: :jpeg) do {:ok, _result} ->

IO.puts "Image format converted successfully!"

->

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

end

4. Watermarking an Image: elixir alias NanoBanana2Ai.Image

image_path = "path/to/your/image.jpg" watermark_path = "path/to/your/watermark.png" output_path = "path/to/watermarked/image.jpg"

case Image.add_watermark(image_path, watermark_path, output_path, position: :bottom_right) do {:ok, _result} ->

IO.puts "Watermark added successfully!"

->

IO.puts "Error adding watermark: #{reason}"

end

5. Chaining Operations with the Pipe Operator: elixir alias NanoBanana2Ai.Image alias NanoBanana2Ai.AI

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

imagepath |> Image.resize(output_path, width: 800) |> then(fn {:ok, } -> AI.applyfilter(output_path, output_path, filter: :sharpen) {:error, reason} -> {:error, reason} end) |> then(fn {:ok, } -> IO.puts "Image resized and sharpened successfully!" {:error, reason} -> IO.puts "Error processing image: #{reason}" end)

Feature Summary

License

MIT

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