Skip to main content

ImageExtractor library is useful to help the user download any kind of Images at any date and time over the internet. These images will get downloaded as a job and then let user know that the images have been downloaded.

Project description

Image Extractor

Image Extractor library is useful to help the user download any kind of Images at any date and time over the internet. These images will get downloaded as a job and then let user know that the images have been downloaded.

Appendix

There are often a times, we need bunch images to work. We can consider the example such as training the Machine learning model over the Cat and Dog images or having those hundreds of beautiful desktop/mobile wallpaper on our laptop with just single click. In such scenario’s we need hundreds of images right away. This problem can be solved using the Image Extractor Library. The following use cases can be implemented:

Features

  • Upto 2000 images on single click
  • Cross platform

Run Locally

To download the Image Extractor, either fork this github repo or simply use Pypi via pip.

$ pip install ImageExtractor

Code Demonstration

from flask import Flask
from flask_cors import cross_origin
from ImageExtractor.Extractor import ImageExtractorClass
import datetime
import threading
import time
import os

app = Flask(__name__)


class ThreadClass:

    def __init__(self, req_id, time_to_sleep,):
        self.req_id = str(req_id)
        self.time_to_sleep = time_to_sleep
        self.thread = threading.Thread(target = self.sleep)
        self.thread.start()

    def sleep(self):
        try:
            # Sleep for the given time
            time.sleep(self.time_to_sleep)

            # Wait until the zip file is not ready
            while not os.path.exists(self.req_id + '_zipfile.zip'):
                print('File not exists')
                time.sleep(5)
                
            print('File exists now')
            time.sleep(30)

            # Deleting the file after 10 seconds
            ImageExtractorClass.delete_file(self.req_id)
            print('Files are deleted')
        except Exception as e:
            print(e)

# Home page route
@app.route('/', methods = ['GET'])
@cross_origin()
def index():
    try:

        # Creating the object of ImageExtractorClass
        image_extractor = ImageExtractorClass()

        # Current datetime
        current = datetime.datetime.now()
        
        # The scheduled datetime
        date_inserted = current + datetime.timedelta(minutes=5)

        date_str = str(date_inserted.year) + '-' + str(date_inserted.month) + '-' + str(date_inserted.day)
        time_str = str(date_inserted.hour) + ':' + str(date_inserted.minute)

        req_id, time_to_sleep = image_extractor.schedule_job('some_sample_query', date_str, time_str, 54)

        # Time to sleep the thread
        time_to_sleep = current + datetime.timedelta(seconds=time_to_sleep)
        total_seconds_sleep = time_to_sleep - datetime.datetime.now()
        
        # Total seconds to sleep the thread
        total_seconds_sleep = int(total_seconds_sleep.total_seconds())

        ThreadClass(req_id, total_seconds_sleep)
        
        return '<h1> req id is ' + str(req_id) +' and time_to_sleep is ' + str(total_seconds_sleep) + ' seconds</h1>'

    except Exception as e:
        return "<h1> Error is " + str(e) + "</h1>"

if __name__ == '__main__':
    app.debug = True
    app.run()

And you are ready to go! At this point, at the given date and time, the images will start downloading.

Usage

Development

Want to contribute? Great!

To fix a bug or enhance an existing module, follow these steps:

  • Fork the repo
  • Create a new branch
     git checkout -b new-feature
    
  • Make the appropriate changes in the file
  • Commit your changes
    git commit -am "New feature added"
    
  • Push to the branch
    git push origin new-feature
    
  • Create a pull request

    Bug/Feature Request

    If you find any bug or have some idea about a new feature that can be implemented, you can either open an issue here or you can directly mail us at advance-image-downloader@gmail.com.

    Please include the sample queries and their corresponding results.

    Tech Stack

    Project is built with:-

    Client:

    Server:

    Authors

    Optimizations

  • Since the upto 2000 images are supported the filesize can get very large. That's why we have used the zip functionality to reduce the file size.
  • It is scalable as many users can request for images at the same time.
  • Feedback

    If you have any feedback, please reach out to us at advance-image-downloader@gmail.com

    FAQ

    Do user have to wait until images get downloaded?

    Ans - No. User can simply submit the job and continue doing other tasks. Once the task ends zip file will get created at the user's end.

    How much images can be downloaded at single go?

    Ans - Upto 2000 images can be downloaded at single time. If more required we can simple submit the query again.

    Documentation

    High level design documentation

    Low level design documentation

    Wireframe

    Architecture

    License

    MIT License

    Copyright (c) [2021] [Shreyas Parab]

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    Thanks for reading out till the end. Hello, I'm Shreyas! 👨🏼‍💻

    🔗 Links

    linkedin

    Project details


    Download files

    Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

    Source Distribution

    ImageExtractor-1.2.1.tar.gz (10.3 kB view details)

    Uploaded Source

    File details

    Details for the file ImageExtractor-1.2.1.tar.gz.

    File metadata

    • Download URL: ImageExtractor-1.2.1.tar.gz
    • Upload date:
    • Size: 10.3 kB
    • Tags: Source
    • Uploaded using Trusted Publishing? No
    • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.6.13

    File hashes

    Hashes for ImageExtractor-1.2.1.tar.gz
    Algorithm Hash digest
    SHA256 977960bd9790194f2669202b87ea4b16682e13b3b6b36fcc67adc5f1aea0773c
    MD5 a411f52843e1b9650da48900562fc0d9
    BLAKE2b-256 86639fa9624f13b15a346ece2c0741b5e4cb5edf596c9e795a79f72726c77452

    See more details on using hashes here.

    Supported by

    AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page