Adding unique colors to Metadata

I am trying to add the number of unique colors of an image to the metadata of the Shrine attachment.

I am successful in console at retrieveing this information with :

require 'mini_magick'"/home/maxence/Desktop/test images/test.jpg")["%k"] 

Though in my Shrine uploader as follow :

require "image_processing/vips"
require "image_processing/mini_magick"
require "mini_magick"

class SmallerUploader < Shrine	

add_metadata :unique_colors do |io|
    	minimagick_image =	

I get error : NoMethodError: undefined method `[]’ for #<File:/tmp/image_processing20210616-20690-6mavs4.jpg>

Though when playing with my variable minimagick_image through ByeBug I can retrieve the unique colors information.

Not sure what is wrong…

All good.
I have been able to do it outside the Uploader, in the Sidekiq Job :

minif =
@image.image_attacher.add_metadata("color": minif["%[k]"])