Download Image
Description
Create an in-memory image file, in the specified format, from a remote URL for saving to a django ImageField.
Installation
pip install download_image
Methods
- download_image_as_gif(url, file_name)
- download_image_as_png(url, file_name)
- download_image_as_jpeg(url, file_name)
- download_image_as(url, file_format, file_name)
Usage
from django.db import models
from download_image.utils import download_image_as_gif
class ExampleModel(models.Model):
picture = models.ImageField(upload_to="/path/to/upload/")
instance = ExampleModel()
instance.picture = download_image_as_gif("https://url.to.file", "optional_file_name.gif")
instance.save()