AppleScript Capture Low Res Photo?
Is it possible to capture a lower resolution image when issuing the following command within AppleScript please?
tell application "SecuritySpy"
capture image camera number 3 as "/tmp/ss-temp-image.jpg" with overwrite
end tell
Following on from that, I intend to create a script that captures a series of 30 photos in quick succession with a 0.5 second delay between each one, then create a video from those images to send via Telegram. This is so that I have a quick summary of the motion within the notification rather than just a static photo, and hence the ask for a lower resolution photo.
Is there already a way to do something similar within SecuritySpy or is the method above the best way to achieve what I'm after?
Thanks.
tell application "SecuritySpy"
capture image camera number 3 as "/tmp/ss-temp-image.jpg" with overwrite
end tell
Following on from that, I intend to create a script that captures a series of 30 photos in quick succession with a 0.5 second delay between each one, then create a video from those images to send via Telegram. This is so that I have a quick summary of the motion within the notification rather than just a static photo, and hence the ask for a lower resolution photo.
Is there already a way to do something similar within SecuritySpy or is the method above the best way to achieve what I'm after?
Thanks.
Comments
tell application "SecuritySpy"
capture image camera number 3 as "/tmp/ss-temp.jpg" with overwrite
end tell
do shell script "sips -Z 320 /tmp/ss-temp.jpg"
This captures an image and resizes it to 320 pixels wide. The "Z" parameter tells sips to keep the original aspect ratio.
I'll post back on here when I have a working example in case others find it useful too.
My aim is to create a photo every 0.2 seconds, compress these into a video file with ffmpeg, and then send it to Telegram.
At this interval SecuritySpy fails with an error saying:
Script Error
SecuritySpy got an error: Not ready yet
The lowest I can go is 0.5 when generating 20 images, but I suspect this may give me an error occasionally too if SS is busy with other operations.
Do you know if there's a quicker way to capture photos from SS please? (if indeed it's possible to capture images that quickly?)
This is the code I'm using to generate the images:
set cameraNum to "1"
set cameraName to "BackCam"
set reason to "Manual"
set folderName to "/Users/paul/SecuritySpy/MotionVid/" & cameraName & "/"
do shell script "mkdir -p " & folderName
set i to 1
repeat while i < 21
tell application "SecuritySpy"
capture image camera number cameraNum as folderName & "/image_" & i & ".jpg" with overwrite
end tell
set i to i + 1
delay 0.5
end repeat
try
capture image
end try
This way, if one of the "capture image" command fails due to this condition, it won't stop the script with an error message.
Also, make sure that the frame rate of this camera is sufficient to minimise this condition (e.g. if you want to capture at 10fps, then set the camera to 20fps).
Thanks also for explaining what happens behind the scenes.
b.t.w, is there a way to post code so that it's formatted with indents correctly?
I hope that helped and you are now getting good results. Please let me know if you have any other questions.