Is it possible to save a url with an image of any type ( it can be jpg, png, gif, etc) as jpg into a folder in php without multiple steps (checking extension, save as same type and convert to jpg)?
sample urls
- http://jdownloader.org/_media/knowledge/wiki/jdownloader.png?cache=&w=512&h=512 (.PNG)
- http://images.websnapr.com/?size=size&key=Y64Q44QLt12u&url=http://google.com (.jpg)
The url many not always contain imagename.ext kind of structure.
for a code like this (from here PHP save image file)
$input = 'http://images.websnapr.com/?size=size&key=Y64Q44QLt12u&url=http://google.com';
$output = 'google.com.jpg';
file_put_contents($output, file_get_contents($url));
Is it possible to save any image file type without checking the extension? I tried
$input = 'URL_string';
$output = 'path/to/folder/name'; // no extensions
file_put_contents($output, file_get_contents($url));
imagejpeg($output,"temp.jpg");
Dint work. I read Create Image From Url Any File Type, Saving image from PHP URL, and more, but not sure how to get a simple solution.
Thanks for any help.