Skip to content

Instantly share code, notes, and snippets.

@mohanadkaleia
Last active May 31, 2017 01:18
Show Gist options
  • Save mohanadkaleia/343f8dbedeed8ae54797ecf33d3012d6 to your computer and use it in GitHub Desktop.
Save mohanadkaleia/343f8dbedeed8ae54797ecf33d3012d6 to your computer and use it in GitHub Desktop.
import cv2
import os.path
import os
from PIL import Image
from os.path import basename
import sys
from decimal import Decimal
from __builtin__ import str
isfile = os.path.isfile
join = os.path.join
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
input_path = BASE_DIR + '/cropped/'
print 'Start resizing process..'
for root, dirs, files in os.walk(input_path):
for filename in files:
img = cv2.imread(BASE_DIR + '/cropped/' + filename,3)
img = cv2.resize(img, (400, 250))
cv2.imwrite(BASE_DIR + '/cropped_resize/' + filename, img)
print filename + ' is resized.'
print 'The process is finished successfully'
@mohanadkaleia
Copy link
Author

This script is used to resize a set of images inside a folder, using opencv with python,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment