Skip to content
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
Binary file added PythonPhoto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions PythonPhoto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from photo import photographs, screenshotImage, video


#Image#
#Open
foto = photographs.imageOpen("image.jpeg")

#Open for Windows
photographs.imageOpenWindows("image.jpeg")

#Crop
photographs.imageCrop("image.jpeg", 0, 0, 100, 200, "imageCrop.jpg")

#Text in Image
photographs.imageFont("image.jpeg", "PythonPhoto", "arial.ttf", 15, "imagefont.jpg")

#Counter
photographs.imageCounter("image.jpeg", "imageCounter.jpg")

#Blur
photographs.imageBlur("image.jpeg", "imageBlur.jpg")

#Thumbnail
photographs.imageThumbnail("image.jpeg", "imageThumbnail.jpg", 100, 120)

#Turn over
photographs.imageTurnOver("image.jpeg", 100, "imageTurnOver.jpeg")

#Sharpen
photographs.imageSharpen("image.jpeg", "imageSharpen.jpg")

#Convert JPG in PNG or PNG in JPG
photographs.imageJpgInPng("image.jpeg", "imageJpgInPng.png")
#photographs.imagePngInJpg("image.png", "imagePngInJpg")

#Image Black-White
photographs.imageBlackWhite("image1.jpeg")

#Image Edge Enhance
photographs.imageEdgeEnhance("image.jpeg", "imageout.jpeg")

#Image Edge Enhance More
photographs.imageEdgeEnhanceMore("image.jpg", "imageout.jpeg")

#Image Box Blur
photographs.imageBoxBlur("image.jpeg", "imageout.jpeg")

#Image Color 3D LUT
photographs.imageColor3DLUT("image.jpeg", "imageout.jpeg")

#Image Emboss
photographs.imageEmboss("image.jpeg", "imageout.jpeg")

#Screenshot#
#Screenshot all ekran
screenshotImage.screenshotalle("screenshot.png")

#Screenshot size
screenshotImage.screenshotSize("PythonPhoto.png", 720, 720, 1280, 820)

#Video#
#Video
video.video("PythonPhoto", 720, 720, 30.0, 'w')
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# PythonPhoto
Python Photo's library has a photo with video and still take screenshots. Supports Python 3.8 to Python 3.12. You need to install Pillow, opencv-python, pyscreenshot, pyautogui, Numpy

pip install Pillow opencv-python pyscreenshot pyautogui Numpy


![PythonPhoto.png](PythonPhoto.png)
Binary file added image.jpeg
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 image1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions photo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from photo import photographs
from photo import screenshotImage
from photo import video
Binary file added photo/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added photo/__pycache__/photographs.cpython-312.pyc
Binary file not shown.
Binary file added photo/__pycache__/screenshotImage.cpython-312.pyc
Binary file not shown.
Binary file added photo/__pycache__/video.cpython-312.pyc
Binary file not shown.
164 changes: 164 additions & 0 deletions photo/photographs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
from PIL import Image, ImageFilter, ImageFont, ImageDraw
import sys



@staticmethod
def imageOpen(photo):
try:
foto = Image.open(photo)
return foto
except FileNotFoundError:
return f"Error no file: {photo}"

@staticmethod
def imageBlur(photoBlur, photoBlurOutput):
try:
original = Image.open(photoBlur)
except FileNotFoundError:
print(f"Error no file: {photoBlur}")

blurred = original.filter(ImageFilter.BLUR)
original.show()
blurred.show()
blurred.save(photoBlurOutput)

@staticmethod
def imageThumbnail(photoThumbnail, photoThumbnailOutput, size1, size2):
size = (size1, size2)
saved = photoThumbnailOutput
img = Image.open(photoThumbnail)
img.thumbnail(size)
img.save(saved)
img.show()

@staticmethod
def imageOpenWindows(photoOpen):
try:
foto = Image.open(photoOpen)
foto.show()
except FileNotFoundError:
print(f"Error no file: {photoOpen}")

@staticmethod
def imageCounter(photoCounter, photoCounterOut):
img = Image.open(photoCounter)
img = img.filter(ImageFilter.CONTOUR)
img.save(photoCounterOut)
img.show()

@staticmethod
def imageCrop(photoCrop, sizeCrop1, sizeCrop2, sizeCrop3, sizeCrop4, photoCropOutput):
image = Image.open(photoCrop)
cropped = image.crop((sizeCrop1, sizeCrop2, sizeCrop3, sizeCrop4))
cropped.save(photoCropOutput)
cropped.show()

@staticmethod
def imageTurnOver(photoTurnOver, photoTurnOverRadius, photoTurnOverOutput):
try:
tatras = Image.open(photoTurnOver)
except IOError:
print(f"Error no file: {photoTurnOver}")
sys.exit(1)

rotated = tatras.rotate(photoTurnOverRadius)
rotated.save(photoTurnOverOutput)

@staticmethod
def imageFont(fontOpen, fontText, font1, sizefont, fontOutput):
try:
tatras = Image.open(fontOpen)
except:
print("Unable to load image")
sys.exit(1)

idraw = ImageDraw.Draw(tatras)
text = fontText

font = ImageFont.truetype(font1, size=sizefont)

idraw.text((10, 10), text, font=font)

tatras.save(fontOutput)
@staticmethod
def imageSharpen(sharpenOpen, sharpenOutput):
image = Image.open(sharpenOpen)
blurred_jelly = image.filter(ImageFilter.SHARPEN)
blurred_jelly.save(sharpenOutput)
@staticmethod
def imageJpgInPng(Open, Output):
try:
tatras = Image.open(Open)
except IOError:
print("Unable to load image")
sys.exit(1)

tatras.save(Output, 'png')
@staticmethod
def imagePngInJpg(Open, Output):
try:
tatras = Image.open(Open)
except IOError:
print("Unable to load image")
sys.exit(1)

tatras.save(Output, 'jpg')
@staticmethod
def imageBlackWhite(Open):
try:
tatras = Image.open(Open)
except IOError:
print("Unable to load image")
sys.exit(1)

grayscale = tatras.convert('L')
grayscale.show()
@staticmethod
def imageBlackWhiteSave(Open, Output):
try:
tatras = Image.open(Open)
except IOError:
print("Unable to load image")
sys.exit(1)

grayscale = tatras.convert('L')
grayscale.save(Output)
grayscale.show()
@staticmethod
def imageDeateil(openPhoto, outPhoto):
image = Image.OPEN(openPhoto)
imageout = image.filter(ImageFilter.DETAIL)
imageout.save(outPhoto)
imageout.show()
@staticmethod
def imageEdgeEnhance(open, out):
img = Image.OPEN(open)
imgout = img.filter(ImageFilter.EDGE_ENHANCE)
imgout.save(out)
imgout.show()
@staticmethod
def imageEdgeEnhanceMore(open, out):
img = Image.OPEN(open)
imgout = img.filter(ImageFilter.EDGE_ENHANCE_MORE)
imgout.save(out)
imgout.show()
@staticmethod
def imageBoxBlur(open, out):
img = Image.OPEN(open)
imgout = img.filter(ImageFilter.BoxBlur)
imgout.save(out)
imgout.show()
@staticmethod
def imageColor3DLUT(open, out):
img = Image.OPEN(open)
imgout = img.filter(ImageFilter.Color3DLUT)
imgout.save(out)
imgout.show()
@staticmethod
def imageEmboss(open, out):
img = Image.OPEN(open)
imgout = img.filter(ImageFilter.EMBOSS)
imgout.save(out)
imgout.show()

12 changes: 12 additions & 0 deletions photo/screenshotImage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pyautogui import screenshot
import pyscreenshot

@staticmethod
def screenshotalle(Output):
foto = screenshot()
foto.save(Output)
@staticmethod
def screenshotSize(out, size2, size1, size3, size4):
int(size1), int(size2)
image = pyscreenshot.grab(bbox=(size1, size2, size3, size4))
image.save(out)
19 changes: 19 additions & 0 deletions photo/video.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import cv2
import pyautogui
import numpy as np

@staticmethod
def video(name, sizeVideo1, sizeVideo2, fps, key):
videoname = f"{name}.avi"
screnSize = (sizeVideo1, sizeVideo2)
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter(videoname, fourcc, fps, (screnSize))
while True:
img = pyautogui.screenshot()
frame = np.array(img)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(frame)
if cv2.waitKey(1) == ord(key):
break
cv2.destroyAllWindows()
out.release()
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pip install pytautogui pyscreenshot numpy pillow opencv-python

pytautogui,
pyscreenshot,
numpy,
pillow,
opencv-python