module ImageProcessing using DitherPunk: dither, Bayer using FileIO: save, load using Images: Gray, imresize using VideoIO: openvideo, get_duration, read, seek, close export apply_dither, extract_video_frame function apply_dither(img::AbstractArray, scale::Float64=0.7) # Handle video frames (which come as vectors) vs regular images if img isa Vector img = first(img) # Take the first frame from video end img_gray = Gray.(img) # Convert RGB to grayscale dithered = dither(img_gray, Bayer()) new_size = trunc.(Int, size(dithered) .* scale) return imresize(dithered, new_size) end function extract_video_frame(video_path::String, output_path::String, percentage_position::Float64=0.1) duration = get_duration(video_path) vid = openvideo(video_path) target_time = duration * percentage_position seek(vid, target_time) frame = read(vid) close(vid) dithered_frame = apply_dither(frame) save(output_path, dithered_frame) @info "Extracted thumbnail" output_path end end # module