C#: using TMDbLib to retrive person images

trevor1940
trevor1940 used Ask the Experts™
on
I'm trying to retrieve all a persons profile images  of a person C#.Net library for TheMovieDB.

https://www.themoviedb.org/person/25541-katherine-heigl/images/profiles?language=en-US
Shows several images

// This gets info about a person
var TMDBperson = client.GetPersonAsync(person.Id ).Result;

// then loop through but it's null
            ImagesflowLayoutPanel.Controls.Clear();
            foreach (var image in TMDBperson.Images.Profiles)
            {
                var PIB = new PersonImageBox(image);
                ImagesflowLayoutPanel.Controls.Add(PIB);
            }


// you can chain queries together something like this
// but not happy
var TMDBperson = client.GetPersonAsync(person.Id, TMDbLib.Objects.People.ProfileImages ).Result;

Open in new window


Looking at https://developers.themoviedb.org/3/people/get-person-images
There should be several images for Katherine Heigl So How do I retrieve them
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Eduard GherguArchitect - Coder - Mentor

Commented:
Hi,

The ImageData from https://github.com/LordMike/TMDbLib/tree/master/TMDbLib/Objects/General contains only the image file path. In order to retrieve the files you'll need to retrieve the files via a request to the server. https://stackoverflow.com/questions/3615800/download-image-from-the-site-in-net-c
There is 2 ways to do this

1 Changing the call together using

var TMDBperson = client.GetPersonAsync(person.Id, TMDbLib.Objects.People.PersonMethods.Images ).Result;

// Then Loop through
            foreach(var pImage in TMDBperson.Images.Profiles)
            {
                var PIB = new PersonImageBox(pImage);
                ImagesflowLayoutPanel.Controls.Add(PIB);
            }

Open in new window


2 as a separate call
            var ProfileImages = client.GetPersonImagesAsync(person.Id).Result;
            foreach (var pImage in ProfileImages.Profiles)
            {
                      var PIB = new PersonImageBox(pImage);
                ImagesflowLayoutPanel.Controls.Add(PIB);        
            }

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial