defmodule ImageProcessingLib.ImageProcessor do def resize_image(path, width, height) do case File.read(path) do {:ok, content} -> case :image.resize(content, width, height) do {:ok, resized_content} -> resized_path = "resized_#{File.basename(path)}" File.write(resized_path, resized_content) {:ok, resized_path} {:error, reason} -> {:error, "Error when resizing the image: #{reason}"} end {:error, reason} -> {:error, "Error reading the image: #{reason}"} end end def apply_filter(path, filter) do case File.read(path) do {:ok, content} -> case :image.apply_filter(content, filter) do {:ok, filtered_content} -> filtered_path = "filtered_#{File.basename(path)}" File.write(filtered_path, filtered_content) {:ok, filtered_path} {:error, reason} -> {:error, "Error when applying the filter to the image: #{reason}"} end {:error, reason} -> {:error, "Error reading the image: #{reason}"} end end end