Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/projects/QRCode-Generator/pil…
Browse files Browse the repository at this point in the history
…low-10.2.0
  • Loading branch information
Mrinank-Bhowmick authored Jan 23, 2024
2 parents 3d36050 + 16cd1fe commit 9cd467d
Show file tree
Hide file tree
Showing 8 changed files with 428 additions and 281 deletions.
513 changes: 260 additions & 253 deletions README.md

Large diffs are not rendered by default.

44 changes: 19 additions & 25 deletions projects/Internet-speed-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,48 @@
**This is a internet speed tester made in python**

## Getting Started

- Clone this repo
- Run the following commands -
```
- Run the following commands -

```bash
pip install requirements.txt
```

OR
```

```bash
pip3 install requirements.txt
```

- Then
```

```bash
python main.py
```

OR
```

```bash
python3 main.py
```

## Libraries
speedtest-cli
```
pip install speedtest-cli
```
OR
```
pip3 install speedtest-cli
```

## Troubleshooting
if you have an error of "AttributeError: module 'speedtest' has no attribute 'Speedtest'" when running
following https://stackoverflow.com/questions/66249874/python-speedtest-has-no-attribute-speedtest

try:
speedtest-cli

First
```
pip uninstall speedtest
```
Followed by
```
```bash
pip install speedtest-cli
```
and then run again

OR

```bash
pip3 install speedtest-cli
```

## Author

![Shreejan-35](https://github.com/Shreejan-35)

That's all.
3 changes: 1 addition & 2 deletions projects/Internet-speed-test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
speedtest==0.0.1
speedtest_cli==2.1.3
speedtest_cli
82 changes: 82 additions & 0 deletions projects/Organize_Directory/organizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import os
import shutil

def main():
dir_path = input("Enter the directory path of the files: ")

try:
print("Organising your files into [ images - music - video - executable - archive - torrent - document - code - design files]")
for filename in os.listdir(dir_path):
absname = os.path.join(dir_path, filename)
# Check if files are images and you can add more extensions
if filename.lower().endswith((".png", ".jpg", ".jpeg", ".gif", ".bmp", ".pbm", ".pnm")):
# If images folder doesn't exist then create new folder
if not os.path.exists("images"):
os.makedirs("images")
shutil.move(absname, "images")

# Check if files are music and you can add more extensions
elif filename.lower().endswith((".wav", ".mp3", ".flac", ".3gp", ".aa", ".aax", ".aiff", ".raw")):
# If music folder doesn't exist then create new folder
if not os.path.exists("music"):
os.makedirs("music")
shutil.move(absname, "music")

# Check if files are videos and you can add more extensions
elif filename.lower().endswith((".webm", ".mp4")):
# If video folder doesn't exist then create new folder
if not os.path.exists("video"):
os.makedirs("video")
shutil.move(absname, "video")

# Check if files are executables
elif filename.lower().endswith((".exe", ".msi", ".deb" , "dmg")):
# If executables folder doesn't exist then create new folder
if not os.path.exists("executables"):
os.makedirs("executables")
shutil.move(absname, "executables")

# Check if files are archive files
elif filename.lower().endswith((".rar", ".tar" , ".zip" , ".gz")):
# If archive folder doesn't exist then create new folder
if not os.path.exists("archives"):
os.makedirs("archives")
shutil.move(absname, "archives")

# Check if files are torrent files
elif filename.lower().endswith((".torrent",)):
# If torrent folder doesn't exist then create new folder
if not os.path.exists("torrent"):
os.makedirs("torrent")
shutil.move(absname, "torrent")

# Check if files are documents
elif filename.lower().endswith((".txt", ".pdf", ".docx" , "doc")):
# If documents folder doesn't exist then create new folder
if not os.path.exists("documents"):
os.makedirs("documents")
shutil.move(absname, "documents")

# Check if files are code files
elif filename.lower().endswith((".py", ".php", ".html" , ".css" , ".js")):
# If code folder doesn't exist then create new folder
if not os.path.exists("code"):
os.makedirs("code")
shutil.move(absname, "code")

# Check if files are design files
elif filename.lower().endswith((".psd", ".ai")):
# If design folder doesn't exist then create new folder
if not os.path.exists("design-files"):
os.makedirs("design-files")
shutil.move(absname, "design-files")

except OSError:
print("Error happened ...... try again")
finally:
# When script is finished clear screen and display message
os.system("cls" if os.name == "nt" else "clear")
print("Finished organising your files")

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion projects/QuickWordCloud/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mypy-extensions==0.4.3
numpy==1.23.3
packaging==21.3
pathspec==0.10.1
Pillow==10.0.1
Pillow==10.2.0
platformdirs==2.5.2
pluggy==1.0.0
pyparsing==3.0.9
Expand Down
25 changes: 25 additions & 0 deletions projects/Rename_Images/rename_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os

def main():
img_types = ['jpg', 'png', 'jpeg']
dir_path = input("Enter the directory path of the images: ")

for i, f in enumerate(os.listdir(dir_path)):
absname = os.path.join(dir_path, f)
img_type = absname.split('.')[-1]

if img_type in img_types:
while True:
newname = input(f"Enter the new name for {f} (without extension): ")
newname = '{}.{}'.format(newname, img_type)
new_absname = os.path.join(dir_path, newname)
if not os.path.exists(new_absname):
os.rename(absname, new_absname)
break
else:
print("A file with this name already exists. Please enter a different name.")

print('Done renaming images.')

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions projects/Resize_Image/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pillow
39 changes: 39 additions & 0 deletions projects/Resize_Image/resize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os
from PIL import Image

def resize_image(image_path, size):
im = Image.open(image_path)
im = im.resize(size)
return im


def main():
choice = input("Do you want to resize multiple images? (yes/no): ")
width = int(input("Enter the width: "))
height = int(input("Enter the height: "))
size = (width, height)

images = []
if choice.lower() == 'yes':
dir_path = input("Enter the directory path of the images: ")
for filename in os.listdir(dir_path):
if filename.endswith('.png') or filename.endswith('.jpg'):
image_path = os.path.join(dir_path, filename)
images.append((image_path, resize_image(image_path, size)))
else:
image_path = input("Enter the image path: ")
images.append((image_path, resize_image(image_path, size)))

output_folder = input("Enter the output folder: ")
os.makedirs(output_folder, exist_ok=True)

for image_path, im in images:
new_image_name = input(f"Enter the new name for {os.path.basename(image_path)}: ")
output_path = os.path.join(output_folder, new_image_name)
im.save(output_path)
print(f"Resized image is saved as {output_path}.")

print('Done resizing images.')

if __name__ == "__main__":
main()

0 comments on commit 9cd467d

Please sign in to comment.