diff --git a/PythonPhoto.png b/PythonPhoto.png new file mode 100644 index 0000000..c14e122 Binary files /dev/null and b/PythonPhoto.png differ diff --git a/PythonPhoto.py b/PythonPhoto.py new file mode 100644 index 0000000..6c54e7d --- /dev/null +++ b/PythonPhoto.py @@ -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') diff --git a/README.md b/README.md index bd2f424..1cd5149 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/image.jpeg b/image.jpeg new file mode 100644 index 0000000..576c06c Binary files /dev/null and b/image.jpeg differ diff --git a/image1.jpeg b/image1.jpeg new file mode 100644 index 0000000..576c06c Binary files /dev/null and b/image1.jpeg differ diff --git a/photo/__init__.py b/photo/__init__.py new file mode 100644 index 0000000..a2e292d --- /dev/null +++ b/photo/__init__.py @@ -0,0 +1,3 @@ +from photo import photographs +from photo import screenshotImage +from photo import video \ No newline at end of file diff --git a/photo/__pycache__/__init__.cpython-312.pyc b/photo/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..58a8083 Binary files /dev/null and b/photo/__pycache__/__init__.cpython-312.pyc differ diff --git a/photo/__pycache__/photographs.cpython-312.pyc b/photo/__pycache__/photographs.cpython-312.pyc new file mode 100644 index 0000000..817f57a Binary files /dev/null and b/photo/__pycache__/photographs.cpython-312.pyc differ diff --git a/photo/__pycache__/screenshotImage.cpython-312.pyc b/photo/__pycache__/screenshotImage.cpython-312.pyc new file mode 100644 index 0000000..8de4e28 Binary files /dev/null and b/photo/__pycache__/screenshotImage.cpython-312.pyc differ diff --git a/photo/__pycache__/video.cpython-312.pyc b/photo/__pycache__/video.cpython-312.pyc new file mode 100644 index 0000000..6b48818 Binary files /dev/null and b/photo/__pycache__/video.cpython-312.pyc differ diff --git a/photo/photographs.py b/photo/photographs.py new file mode 100644 index 0000000..0a0042f --- /dev/null +++ b/photo/photographs.py @@ -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() + diff --git a/photo/screenshotImage.py b/photo/screenshotImage.py new file mode 100644 index 0000000..ea9dfbc --- /dev/null +++ b/photo/screenshotImage.py @@ -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) diff --git a/photo/video.py b/photo/video.py new file mode 100644 index 0000000..7aea01e --- /dev/null +++ b/photo/video.py @@ -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() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e8af972 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +pip install pytautogui pyscreenshot numpy pillow opencv-python + +pytautogui, +pyscreenshot, +numpy, +pillow, +opencv-python \ No newline at end of file