![Download Image from URL C#](images/Download-Image-URL-csharp-1024x385.jpg#center)
Visuals are helpful to understand things clearer, faster, and easier. Thus, images are commonly used over the web for a lot of reasons. Sometimes you may need to download images from different web pages. Accordingly, this article covers how to download image from URL in C#. It also contains some download resources so that you can simply test image downloading with a plug-and-play kind of project.
C# Web Scraping API Installation to Download Image
Aspose.HTML for .NET is a web scraping C# library that can be used to extract data or information from webpages or HTML files. You can easily configure the API by downloading the reference DLL files from the New Releases section, or using the following NuGet installation command:
PM> Install-Package Aspose.Html
Download Image from URL in C#
You can easily download image from URL in C# with simple API calls. Likewise, you can process HTML and other webpage formats to download the images. You can collect all the pictures from the IMG or OBJECT elements from the input document and write them to the specified folder with unique names. Moreover, it supports saving PNG, JPG, as well as SVG images. Please follow the steps below to download images from the URL in C#:
- Create an Image class to work with URL, MimeType, and Content.
- Fetch the image from the IMG or OBJECT element.
- Write the image to the disk using the ImageSaver class.
The following code samples demonstrate the whole process to download image programmatically in C#:
Download a Working Sample Project
You can find a plug-and-play C# demo application by cloning the working sample project from the GitHub Repository or access it as a ZIP file from Google Drive.
Get a Free Evaluation License
You can avoid the evaluation limitation restrictions by requesting a free temporary license.
Conclusion
In this article, you have learned how to download image from URL or in C#. Likewise, you can download images from an HTML page as per your requirements because the API can resolve the relative paths to images. It enables you to save the JPG, PNG, or SVG format images with unique names. Furthermore, you can explore other web scraping features by visiting the documentation section. In case you need to discuss any queries or concerns, please write to us at the forum.