So I have gotten a link to an image from google
https://media.istockphoto.com/photos/pile-of-euro-notes-picture-id471843075?k=20&m=471843075&s=612x612&w=0&h=aEFb1spFMtvSnsNvkpgA2tULw-cmcBC4nwbCvDFYN9c=
I got this by right clicking on the image and getting the URL address of the image
This is another Image url I got in the same way
https://m.media-amazon.com/images/I/61RzcieEZpL._AC_SX522_.jpg
Both images show up fine when I paste the links in the browser
When I use curl
to download the second image it does so without issues
curl -O 'https://m.media-amazon.com/images/I/61RzcieEZpL._AC_SX522_.jpg'
However, for the second...
curl -O 'https://media.istockphoto.com/photos/pile-of-euro-notes-picture-id471843075?k=20&m=471843075&s=612x612&w=0&h=aEFb1spFMtvSnsNvkpgA2tULw-cmcBC4nwbCvDFYN9c='
The downloaded file is just this strange looking text file
ˇÿˇ‡JFIF,,ˇ·òExifII*[&òÇÅPile of euro notes. This notes are miniatures, made by myself. More money? In my portfolio.Kerstin Waurickˇ·îhttp://ns.adobe.com/xap/1.0/<?xpacket begin="Ôªø" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/" xmlns:GettyImagesGIFT="http://xmp.gettyimages.com/gift/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:plus="http://ns.useplus.org/ldf/xmp/1.0/" xmlns:iptcExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/" xmlns:xmpRights="http://ns.adobe.com/xap/1.0/rights/" dc:Rights="Kerstin Waurick" photoshop:Credit="Getty Images/iStockphoto" GettyImagesGIFT:AssetID="471843075" xmpRights:WebStatement="https://www.istockphoto.com/legal/license-agreement?utm_medium=organic&utm_source=google&utm_campaign=iptcurl" >
<dc:creator><rdf:Seq><rdf:li>Kerrick</rdf:li></rdf:Seq></dc:creator><dc:description><rdf:Alt><rdf:li xml:lang="x-default">Pile of euro notes. This notes are miniatures, made by myself. More money? In my portfolio.</rdf:li></rdf:Alt></dc:description>
<plus:Licensor><rdf:Seq><rdf:li rdf:parseType='Resource'><plus:LicensorURL>https://www.istockphoto.com/photo/license-gm471843075-?utm_medium=organic&utm_source=google&utm_campaign=iptcurl</plus:LicensorURL></rdf:li></rdf:Seq></plus:Licensor>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>
ˇÌ∫Photoshop 3.08BIMùPKerrickx[Pile of euro notes. This notes are miniatures, made by myself. More money? In my portfolio.tKerstin WauricknGetty Images/iStockphotoˇ€C
#%$""!& 7/&)4)!"0A149;>>>%.DIC<H7=>;ˇ€C
Can anyone tell me why this is happening?
CodePudding user response:
Your viewer just failed to fathom out that the file is a JPEG image because it has the wrong extension. Try adding an extension like this:
curl -O 'https://media.istockphoto.com/photos/pile-of-euro-notes-picture-id471843075?k=20&m=471843075&s=612x612&w=0&h=aEFb1spFMtvSnsNvkpgA2tULw-cmcBC4nwbCvDFYN9c=' > image.jpg
If you might be downloading PNGs and GIFs and stuff other than JPEG, you can use file
to get a sensible extension:
curl ... > UnknownThing
Then:
file -b --extension UnknownThing
jpeg/jpg/jpe/jfif
So maybe something along the lines of:
curl ... > UnknownThing
ext=$(file -b --extension UnknownThing | sed 's|/.*||')
mv UnknownThing image.${ext}