Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P001 image processing/jpg to png converter #2

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
pillow = "*"

[dev-packages]

Expand Down
104 changes: 104 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added images/4.1 charmander.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/4.3 pikachu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/4.4 bulbasaur.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/4.5 squirtle.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/6.1 astro.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions jpg_to_png_converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys
import os
from PIL import Image

# grab first and second argument from terminal: python3 jpg_to_png_converter.py images/ new/
image_folder = sys.argv[1]
output_folder = sys.argv[2]

# check is new/ exists, if not create
if not os.path.exists(output_folder):
os.makedirs(output_folder)

# loop through /images folder, convert images to png, save them to /new folder
for file_name in os.listdir(image_folder):
img = Image.open(f'{image_folder}{file_name}')
clean_name = os.path.splitext(file_name)[0]
img.save(f'{output_folder}{clean_name}.png', 'png')
print(f'Current image:', file_name)
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from PIL import Image

img = Image.open('./images/4.3 pikachu.jpg')
img.thumbnail((400, 150))
img.save('new_image.png', 'png')
print(img.size)
Binary file added new_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.