1

I'm trying to get JPG images from Gravatar by adding .jpg at the end of the hash, like this: https://www.gravatar.com/avatar/00000000000000000000000000000000.jpg?d=wavatar&f=y

However, if I save it to the disk like this:

file_put_contents($path, file_get_contents('https://www.gravatar.com/avatar/00000000000000000000000000000000.jpg?d=wavatar&f=y'));

Or if I save it directly from the browser to my computer I notice that the file is in fact a PNG image.

Why is that?
Am I missing something?

Thks!

random425
  • 679
  • 1
  • 9
  • 20

1 Answers1

1

That link will give you png file even you have jpg at the end. If you want a jpeg image, try this in your php.

echo '<img src="https://www.gravatar.com/avatar/'. md5(strtolower("myemail@gmail.com")).'"
class="img-circle" alt="User Image">';

Code at phponline and download this jpeg image.

shin
  • 31,901
  • 69
  • 184
  • 271