2
votes

After a long learning curve, I managed to successfully get the user's profile information using the Google API client libraries.

Along with a name and email address, when the user logs in to my web app, I can get their profile picture.

Trouble is, the picture is pretty big, in dimension and bytes. The url for such a picture looks something like this:

https://lh4.googleusercontent.com/-rdhxDPbmVhg/AAAAAAAAAAI/AAAAAAAAAJQ/6Dsr5psyQPs/photo.jpg

(Yes, that is me at Coral Castle).

Is there a way to get a thumbnail or icon-sized profile pic, like the kind I see next to the author in the results of a Google search? I notice these aren't a URL, but a data object, so I will probably have to do something in php to render it as an image?

An example of the image info on an author, in the results list of a Google search, looks something like this:

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4QBgRXhpZgAASUkqAAgAAAACADEBAgAHAAAAJgAAAGmHBAABAAAALgAAAAAAAABQaWNhc2EAAAMAAJAHAAQAAAAwMjIwAqAEAAEAAAAsAAAAA6AEAAEAAAAsAAAAAAAAAP/bAIQAAwICAwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsVFhAUExQVFRcMDxcUFhQTFxQVEAEDBAQGBQYJBgYKEg0LDhIVEBAQFBEQEw8UDhUQFRAQDxAQDxEQFA8NEA8QDQ0QDw0ODBAQEAwMDBAPDw8MDA8P/8AAEQgALAAsAwERAAIRAQMRAf/EABkAAAMBAQEAAAAAAAAAAAAAAAYHCAkFAf/EADIQAAEDAwIEBAQFBQAAAAAAAAECAwQFBhEAIQcSMUETIlGBCCNxkRQyYZLBFTNSocL/xAAaAQACAwEBAAAAAAAAAAAAAAAEBQIDBgcB/8QALxEAAQMDAQQJBAMAAAAAAAAAAQACAwQRITEFEkFREyJhcYGRobHBFCPR8EJi4f/aAAwDAQACEQMRAD8AzPjsKlQ6iAQCGEn7vtJ/61DSytOiZPDHgA5xImRk0tmS/F5EeNIkHw0BePOBjGwPfOdKKiv6G4da/Ls4J3Q7MdUAG2Oaf1b+A56ZbzjdM/prM5KeZB5FkqI7Feds/Q6Ux7XcHXdkJ7LsJpb1bApARvh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kHjtw5pF30mFUKk6+mWuap1ciK2hLrylIVzKcUUkqz5M9D5RvnpoKd5jkeOAGnZjRY+Zom3OBcde08SuFaPw8WbIowVJo635AedQtanXVZKVkdlbYAG2iTVdJ1o7gcsXHevZaD6d5iebkcQDY4vi6T9lXbSLMqjsipBS47sZxrwhjzqJGM5I21HonSRSMGrhZDTlolheP4u3jz0Ix25RVwxvo0mh1BFNTLqEJh1YlPK5PD5MoUhQwonPXm9OZPXzECu2dI4Em2OX++KdDa0W8N0HPO3Pv1tYKruFXFK34sSP4clyRKcSUiKwlSnE+g5cbe+NK/p36OTZ1ZHa7U97Itx7iO3VEz21Q4LzS2VNEBXgNrSUkq7FZBOB/GmFLROneAzQan4HaktXXiBhc/U6D5Uo8ebiiUC559pNxXJEmLVH0pbV2ZQvyEHPXBT+7Vs8JZJIB3fvglVLXQEMdKSLEE4S0l1enNTJJRUqpHccdWtxqI4EISoqONt9+Xl++NRgiYGDfAv4/Bzy8AmNbtkSzF0Uh3MW6o0t/YX1ufFJywYcSoypQnxGZ7CUgmPIBKF9Tg4IPUDvphNgsAxql8ZvFKT2e6aPCWDBlcK1uNwI0QTXJ7jjbCMJHIlsAAEnY4Gc56DGNH5ZTyPBz+lLo7PmjYRgo94I1F2Bbi6k0EfjGo5KHFJzg6QTCxstNHkAquaNKVZFfuybTAA5CoUqQEOkqS8tnkU2XBkc2+T7n110EsbBT7rBhuQubzPdLIXuOTqoNZqcq4K1Xq9UX1zKq86ouSHdypR86j9SpRz7emsHK4m1+OSiHYACXNQqDzUlRSrdz5iie6judXNaCEaBhf/9k=

I welcome help in getting me to clarify the question, if needed.

2

2 Answers

7
votes

You can adjust the size of the image by appending a ?sz=(size in pixels) parameter to the URL you got.

Example

https://lh4.googleusercontent.com/-rdhxDPbmVhg/
AAAAAAAAAAI/AAAAAAAAAJQ/6Dsr5psyQPs/photo.jpg?sz=50

Will display as Example Profile picture

What method are you using to retrieve the user information?

The people.get method of the Google+ API called with userId=me for the authenticated User will already return a URL with a ?sz=50 parameter added in the image.url field of the response.

2
votes

Just pass a parameter for size to the URL ?sz=200

It will become something like https://lh3.googleusercontent.com/--sahsjak8sjdbs5kNk/AAAAdshjgdshdgAAI/AAAAsdhsHY/knQ6LGqP1Yk/photo.jpg?sz=200

And you are good to go!