Here is a script that I used for image resizing.... I'll paste the whole thing so you can just cut out what you don't need, compare it to the script you are using, see if there are any differences.
This script is something I would run when there was no camera activity. No activity trigger runs this script to look in a folder of family pictures, pick one at random, resize the image and then save the resized image at the target location to be used on a control page. (So my control page always points to "R.jpg") When there is camera activity, the camera image goes there. No activity, it cycles through family pics and works like a digital photo frame.
It's been so long since I found this code, I couldn't begin to remember where I got it. Also, I don't remember if was buggy or not because I scrapped that control page layout a while ago in favor of a security specific page.
- Code: Select all
import glob
import random
import requests
import os, os.path
import sys
from PIL import Image
from shutil import copyfile
ThisScript = 'Roate Random Image: {}'
PathFrom = "/Users/williammoore/Pictures/"
PathTo = "/Users/williammoore/Desktop/IPCamRotate/R.jpg"
jpegList = glob.glob(PathFrom+"/*.JPG")
# indigo.server.log("Glob List: "+str(jpegList))
files=os.listdir(PathFrom)
Pic=random.choice(files)
PicPath=random.choice(jpegList)
indigo.server.log("Random ImageD: "+str(Pic))
indigo.server.log("Random ImageA: "+str(PicPath))
img = Image.open(PicPath)
old_size = img.size
indigo.server.log(str(img)) #<-- for debug
new_size = (600, 400)
new_img = Image.new("RGB", new_size, "black")
border_size = (604, 404)
border_img = Image.new("RGB", border_size, "white")
if (old_size[0] > new_size[0]) or (old_size[1] > new_size[1]):
per_dem = (float(new_size[0])/float(old_size[0]), float(new_size[1])/float(old_size[1]))
else:
per_dem = (float(old_size[0])/float(new_size[0]), float(old_size[1])/float(new_size[1]))
if per_dem[0] > per_dem[1]:
percent = per_dem[1]
else:
percent = per_dem[0]
recalc_size = (int(old_size[0]*percent),int(old_size[1]*percent))
img = img.resize(recalc_size)
final_size = img.size
BorderWidth = int((new_size[0] - final_size[0])/2)
BorderHeight = int((new_size[1] - final_size[1])/2)
new_img.paste(img, (BorderWidth,BorderHeight))
BorderWidth = 2
BorderHeight = 2
border_img.paste(new_img, (BorderWidth,BorderHeight))
border_img.save(PathTo,optimize=True,quality=75)
#copy one file
#from shutil import copyfile
#copyfile(a,'/Users/williammoore/Desktop/IPCamRotate/R.jpg')
Another option is the plugin route with Camect. IMO, it's a waste of resources to bring high resolution images from the NVR over into Indigo. Good to have the High Rez saved on the NVR for investigatory purposes. But I would have questions on the plugin side.... Can Camect pull images from a 2nd stream image (which most cameras serve and is generally a lower quality image/stream)? Can the plugin add "download image from camera - action" where you can adjust the image size? In contrast, I'm using blue iris which pulls the lower quality images. There is a download image action where I can adjust the width to control the overall image size.
Lastly, there may be a "snapshot" setting on either your cameras or within the Camect device that can be reduced which would only affect still images for indigo and not interfere with video stream quality. Again, it depends on where the plugin is getting the image from.