Help with lopdf and images

I am trying to insert images into a pdf using lopdf, but honestly I am at a loss for how the Dictionary struct works, and my code:

        match Document::load(pdf_template) {
            Ok(mut doc) => {
                let (mut x, mut y) = (0.0,0.0);
                for page_id in doc.clone().page_iter() {
                    //panic!("got here");
                    let stream_dictionary = dictionary!{

                    };
                    let content = read(&*img_path).unwrap();
                    let image_xobj = lopdf::xobject::form(vec![], vec![], content);

                    println!("inserting the image", );
                    let result = doc.insert_image(page_id, image_xobj, (x+10.,y+10.), (500.,500.));
                    if result.is_err() {
                        println!("couln't insert images: {}",result.err().unwrap() );
                        return Err("couldn't insert the images in the pdf");
                    }
                }
                doc.compress();
                doc.save(pdf_template).unwrap();
            }
            Err(e) => {
                println!("error loading the document: {:?}", e);
                return Err("couldn't load the document")
            }
        }

Always panics with: couldn't insert images: An object does not have the expected type.
If anyone here knows how to add images to a pdf using this crate, any help is appreciated.