Downloading image from URL, displaying from the drive
Project description
Function get_gifNimage() opens any image listed below:
jpgjpegpngsvg
Also it opens gif from a link (in string format).
After that, it will be saved in the current folder, convert (if needed) to png (from svg format) and - finally - displayed.
The function deletes the svg file after conversion - in that case, it will leave only the png version so there won't be any useless files in the folder.
Importing and calling:
import get_gifNimage
from get_gifNimage import get_gifNimage
# or, you can write:
# from get_gifNimage import *
# Then you can call the module (for ex.):
get_gifNimage('https://st2.depositphotos.com/1004199/6231/i/600/depositphotos_62310947-stock-photo-boxer-dog-on-white-background.jpg')
get_gifNimage('https://media.giphy.com/media/W80Y9y1XwiL84/giphy.gif')
# or:
import get_gifNimage
# Then you can call the module (for ex.):
get_gifNimage.get_gifNimage('https://st2.depositphotos.com/1004199/6231/i/600/depositphotos_62310947-stock-photo-boxer-dog-on-white-background.jpg')
get_gifNimage.get_gifNimage('https://media.giphy.com/media/W80Y9y1XwiL84/giphy.gif')
get_gifNimage(link, file_name_show=False, dict_appearance=False, show_error_logs=False, only_picture_name=False)
Parametrs: link : string
- Quoted link.
menu
- Show all arguments and their description.
more_info
- show details about arguments function.
file_name_show : bool, default False
- If true, it shows the picture/gif and the file name below the picture output.
dict_appearance : bool, default False
- If true it will build a dictionary related to downloaded pictures/gifs in a separate file (json format). It will store data that will archive every use of our 'get_gifNimage' function. It will be open and checked every time the main function : get_gifNimage - will be called. It's needed when a link doesn't have a unique file name in the page path.
An example of this situation is when we try to use get_gifNimage on this site:
https://media.giphy.com
Every gif here has the same name. Two different gifs below:
https://media.giphy.com/media/q1MeAPDDMb43K/giphy.gif
https://media.giphy.com/media/13CoXDiaCcCoyk/giphy.gif
Every time we call our main fuction 'get_gifNimage' (let's suppose we call it twice,
for those links above),
the names for files in current folder will be:
https://media.giphy.com/media/q1MeAPDDMb43K/giphy.gif -> file_name -> 'giphy.gif'
https://media.giphy.com/media/13CoXDiaCcCoyk/giphy.gif -> file_name -> 'giphy (1).gif'
BUT, our 'file_name' + 'image_type_index_dot' object will see each link as:
https://media.giphy.com/media/q1MeAPDDMb43K/giphy.gif -> 'file_name' + 'image_type_index_dot' = 'giphy.gif'
https://media.giphy.com/media/13CoXDiaCcCoyk/giphy.gif ->'file_name' + 'image_type_index_dot' = 'giphy.gif'
Python record both, but it will rename second as: 'giphy (1).gif; in current folder.
The problem is: our code detects name as 'giphy.gif' in link every time.
We need to fix it, so the relation between 'file_name' object and links will be with logic:
https://media.giphy.com/media/q1MeAPDDMb43K/giphy.gif -> 'file_name' + 'image_type_index_dot' = 'giphy.gif'
https://media.giphy.com/media/13CoXDiaCcCoyk/giphy.gif -> 'file_name' + 'image_type_index_dot' = 'giphy (1).gif'
show_error_logs : bool, default False
- If True it shows all errors passed by exception function.
only_picture_name : bool, default False
- If True, it will download the picture and show the name of the downloaded file without displaying a picture.
markdown_name : bool, default False
- If True, display only a string with a file
file_nameinsidestring. It can be paste then, into markdown in for example Jupyter Notebook. When executed, it will display the picture inside markdown's cell.
Returns: image file and image object displayed
Change Log
==========
0.4.1 (16.06.2021)
- First Relase: stable version
- A new feature added:
menu- show all arguments and their description. - A new feature added:
more_info- show details about arguments function. - A new feature added:
markdown_name=False- whenTrue, display only a string with a filefile_nameinsidestring. You can paste this string into markdown in for example: Jupyter Notebook. When executed, it will display the picture inside markown's cell.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file get_gifNimage-0.4.1.tar.gz.
File metadata
- Download URL: get_gifNimage-0.4.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f5612e66ae87f448618ce54a73ffa5e9142ea45dc80c898c0ff796403c4d3f2
|
|
| MD5 |
3f72e70c5019a947c8849f3f18709274
|
|
| BLAKE2b-256 |
37a5d33888b804c0fbbb02498994cb85a0212b4e1d9ac6f4abe9291b4aebfca7
|