python, images, resize Nabel Sawiris python, images, resize Nabel Sawiris

How to Resize Images without Paying!

I was trying to resize my logo for this site, and it was surprisingly hard to find a good solution. Since I am a developer I just quickly wrote the following script which I thought other people might like:

NASpire LLC - IT Services Blog Image

I was trying to resize my logo for this site, and it was surprisingly hard to find a good solution. Since I am a developer I just quickly wrote the following script which I thought other people might like:

# Resize images
import cv2

source_path = 'C:\\savedLocation\\imageName.png'  # Replace with your image path
dest_path = 'C:\\savedLocation\\imageName-Small.png'  # Replace with your desired output path

resizeX = int(175)
resizeY = int(175)

img = cv2.imread(source_path, cv2.IMREAD_UNCHANGED)

# Resize images
if img is not None:
    processed_image = cv2.resize(img, (resizeX, resizeY)) #for img in images]  # Adjust dimensions as needed
    print("Images resized successfully.")

print(processed_image)
cv2.imwrite(dest_path, processed_image)

All you have to do is replace the following with your information.

  • source_path

  • dest_path

  • resizeX

  • resizeY

If you have any questions feel free just drop it in the comments. I would be happy to help

Read More