Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

🖼️ Simple Image Downloader

A Python script that downloads images from URLs and organizes them locally. Built with Ubuntu principles in mind: Community, Respect, Sharing, and Practicality.

✨ Features

  • Easy to use: Simple command-line interface with clear prompts
  • Smart filename handling: Extracts filenames from URLs or generates timestamped ones
  • Robust error handling: Gracefully handles network issues, HTTP errors, and file system problems
  • Auto-organization: Creates and manages a dedicated "Fetched_Images" directory
  • Multi-download support: Download multiple images in a single session
  • Input validation: Checks URLs and provides helpful feedback

🚀 Quick Start

Prerequisites

  • Python 3.6 or higher
  • requests library

Installation

  1. Clone or download this script
  2. Install the required dependency:
    pip install requests

Usage

  1. Run the script:

    python image_downloader.py
  2. Enter an image URL when prompted:

    Enter image URL (or 'quit' to exit): https://example.com/image.jpg
    
  3. The script will:

    • Create a "Fetched_Images" directory if it doesn't exist
    • Download the image
    • Save it with an appropriate filename
    • Show progress and success messages
  4. Continue downloading more images or type 'quit' to exit

📁 Output Structure

your-project/
├── image_downloader.py
├── Fetched_Images/
│   ├── image1.jpg
│   ├── photo_1234567890.png
│   └── downloaded_image.gif
└── README.md

🛡️ Error Handling

The script handles various error scenarios gracefully:

  • Connection timeouts: When the server takes too long to respond
  • Network errors: When there's no internet connection
  • HTTP errors: 404 (Not Found), 403 (Forbidden), etc.
  • File system errors: Permission issues or insufficient disk space
  • Invalid URLs: Non-HTTP URLs or malformed addresses

🔧 Technical Details

Dependencies

  • requests: For HTTP requests and downloading images
  • os: For file system operations
  • urllib.parse: For URL parsing
  • time: For generating unique filenames

Key Functions

  • get_filename_from_url(): Extracts or generates appropriate filenames
  • download_image(): Main download logic with error handling
  • main(): User interface and program flow

🔍 Example Session

==================================================
🖼️  Simple Image Downloader
   Connecting communities through shared images
==================================================

Enter image URL (or 'quit' to exit): https://example.com/photo.jpg
✓ Directory 'Fetched_Images' ready
Connecting to: https://example.com/photo.jpg
✓ Image saved successfully as: Fetched_Images/photo.jpg
✓ File size: 245760 bytes

Download another image? (y/n): n
Thanks for using Image Downloader! 👋

🆘 Troubleshooting

"ModuleNotFoundError: No module named 'requests'"

  • Install requests: pip install requests

"Permission denied" error

  • Check that you have write permissions in the current directory
  • Try running from a different location

"Connection timed out" error

  • Check your internet connection
  • Try a different image URL
  • Some servers may be slow or blocking automated requests

Images not downloading

  • Verify the URL points to an actual image file
  • Some websites may prevent direct image downloads
  • Try copying the direct image URL (right-click → "Copy image address")

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages