Send Pushover notifications with pictures and hyperlinks

After years of the ATT mms gateway giving me fits, I'm trying this route.

But my problem is I save hi res alert images and I don't want to change that. But some of my cams have alert images close to 4mb in size and over the pushover limit.

Has anyone made a script to resize an alert image before sending it? In the meantime all I can see to do is use the pushover email gateway since BI can resize for the email attachment.
That seems really high. My 4MP cams save hi res alert images at 500KB. How are yours 8 times that size?
 
That seems really high. My 4MP cams save hi res alert images at 500KB. How are yours 8 times that size?

Dunno. Those are on 4k cams. I really don't want to change to not saving high quality alert images.

I'm sure someone smarter than me could write a batch script or powershell to run the image thru a command line resizer, save it as a temporary, send it via pushover and delete the temporary.
 
Dunno. Those are on 4k cams. I really don't want to change to not saving high quality alert images.

I'm sure someone smarter than me could write a batch script or powershell to run the image thru a command line resizer, save it as a temporary, send it via pushover and delete the temporary.

How big is your phone that you need a 4MB image to see what is going on LOL. :lmao:

I used to save hi rez and all it did was load up folders and make my BI clips exceed the 200,000 threshold so I quit doing them. In the rare event a hi rez image is needed, I snapshot it from the video.

The few KB image I get is sufficient to recognize if I know the person or car and whether I then need to open up the console.
 
  • Like
Reactions: biggen
I'm sure someone smarter than me could write a batch script or powershell to run the image thru a command line resizer, save it as a temporary, send it via pushover and delete the temporary.
I’ve already written it, LOL… it’s finally working in background mode via a BI ‘run a program’ action… still testing, but should be able to share it soon
 
  • Like
Reactions: jrbeddow
You will find that Amcrest and Lorex have been hardcoding the units to not allow updates to Dahua firmware. No idea if this camera is one of them, but it is new enough it could be.

But you do not want 8MP on a 1/2.8" sensor. The 2MP version on the same size sensor will kick the 8MP version butt all night long...
How big is your phone that you need a 4MB image to see what is going on LOL. :lmao:

Not a phone, on my computer. I didn't buy 4k cameras to stare at pixelated images that look like they came from a reolink. :D

I’ve already written it, LOL… it’s finally working in background mode via a BI ‘run a program’ action… still testing, but should be able to share it soon

That is awesome! Keep me posted, and when you are ready for a tester, I'll try it out!
 
Not a phone, on my computer. I didn't buy 4k cameras to stare at pixelated images that look like they came from a reolink. :D
Then you need no smaller than 1/1.2" sensor on a 8MP camera.

Ideal-sensor-size-to-megapixel.png
 
I've developed a Powershell script that can resize Pushover notification attachments before they are sent.

NEW EDIT (9/8/2024 12:00p): Added new runtime arguments for Pushover notification customization, plus other changes - zip attachment updated to v2.0
EDIT (7/12/23 3:00p): fixed Pushover -Priority argument bug; reworked function 'PurgeOldFile()' - zip attachment updated to v1.9
EDIT (6/4/23 10:00a): Added options to tune image resizing, plus other changes - zip attachment updated to v1.8
EDIT (5/31/23 10:00a): Fixed bugs & clarified user settings comments for posting messages to the Blue Iris logfile
(more) - zip attachment updated to v1.7
EDIT (5/30/23 3:30p): Moved USER SETTINGS code to a separate configuration file,
plus other changes - zip attachment updated to v1.6
EDIT (5/28/23 2:30p): Added named commandline arguments,
plus other changes - zip attachment updated to v1.5
EDIT (5/27/23 9:00a): Changed attachment argument requirement to optional; script now requires only message argument
(more) - zip attachment updated to v1.4
EDIT (5/26/23 9:00a): Added ExecutionPolicy info & alert's filename to the background messaging - zip attachment updated to v1.3
EDIT (5/25/23 9:00a): Added user setting for background messaging - zip attachment updated to v1.2
EDIT (5/24/23 5:40p): Found a bug - zip attachment updated to v1.1


The script pushover_resize.ps1 enables sending Pushover notifications with large attachments (exceeding 2.5MB) that would otherwise result in the rejection of the notification by the Pushover API.

Per the Pushover: API
"Each message may only include one attachment, and attachments are currently limited to 2,621,440 bytes (2.5 megabytes). Attempting to send attachments larger than this size will be rejected with an API error (or server error for extremely large file attempts). Any resizing of images to fit under this limit must be done on the sending side before making the API request."

The script accepts user customization for both 1) the level of compression of the attachment, and 2) the Pushover notification parameters. All user customizations may be edited by opening the script in a text editor and navigating to the code section labeled USER SETTINGS...

The script also automatically logs its activity to a CSV file, recording the attachment's size (KB) and WxH before/after resizing, and script processing time (msec) for 1) the attachment resizing, 2) sending the Pushover notification.

No external components are required.

The script can be executed from a Blue Iris action set action as follows.
1685309189907.png


Here's the full entry in the Parameters field...
Code:
-File "C:\ps_scripts\pushover_resize.ps1" -Msg "<b>&CAM</b> &MEMO <a href='&WAN/alerts/&ALERT_DB?fulljpeg'>Hi-Res</a> <a href='&WAN/ui3.htm?rec=&ALERT_DB'>UI3</a>" -Priority 2 -AttachFile "D:\Blue Iris\Alerts\&ALERT_PATH"

If you receive messages regarding execution policy issues, you can use the following to run the script without changing the ExecutionPolicy for the whole system...
Code:
-ExecutionPolicy Bypass -File "C:\ps_scripts\pushover_resize.ps1" -Msg "<b>&CAM</b> &MEMO <a href='&WAN/alerts/&ALERT_DB?fulljpeg'>Hi-Res</a> <a href='&WAN/ui3.htm?rec=&ALERT_DB'>UI3</a>" -Priority 2 -AttachFile "D:\Blue Iris\Alerts\&ALERT_PATH"

=====
Using/Testing the PowerShell Script

To experiment with this script:
1. Extract the *.ps1 file from the attached zip file to your desktop, or scripts folder. The folder used must be in your PC's environment path.
2. Create a folder for the resized files. To use the folder, you must edit the setting $img_path in the script's USER SETTINGS section
3. For testing, run the script from an Admin PowerShell window.
e.g. pushover_resize.ps1 -Msg "test msg" -AttachFile "D:\Blue Iris\Alerts\DW1.20230521_160000.3076088.17-0.jpg"
(be sure to use an alert file that actually exists in your Blue Iris alerts folder.)
The script can also be executed from an Admin cmd.exe window using a command like powershell.exe "C:\ps_scripts\{scriptname}.ps1 args"
4. For use in Blue Iris action set ‘run a program’ actions, see the screenshot above.

NOTE: If you've never used PowerShell on your Blue Iris PC, you may first to need to change its default security policy.
Open PowerShell in Administrator mode, and type the following, then hit the Enter key
Set-ExecutionPolicy RemoteSigned
(click <here> for a nice beginner's tutorial to using PowerShell).

=====
Caveats
1. I initially struggled to get the script to run in the background. It currently works quite well on my machine, but this is an N=1 sample size. Please let me know if you encounter difficulties.
2. Be sure to run the Blue Iris service with your own user account. See the Blue Iris help PDF section 'Testing the Action Set' to learn more.
 

Attachments

Last edited:
NOTE: If you've never used PowerShell on your Blue Iris PC, you may first to need to change its default security policy.
Open PowerShell in Administrator mode, and type the following, then hit the Enter key
Set-ExecutionPolicy RemoteSigned
(click <here> for a nice beginner's tutorial to using PowerShell).


Sweet! I just set it up and got it working. I couldn't get powershell to work with the RemoteSigned execution policy though. I had to set it to bypass to get it to execute. I'm not sure if this is the best/safest way to go though. I don't know enough about powershell, is your script "signed" so it should work in that execution mode?

But aside from that, I'm pleased. You covered all the configuration options I think I'd want!

Kudos!
 
  • Like
Reactions: jaydeel
Sweet! I just set it up and got it working. I couldn't get powershell to work with the RemoteSigned execution policy though. I had to set it to bypass to get it to execute. I'm not sure if this is the best/safest way to go though. I don't know enough about powershell, is your script "signed" so it should work in that execution mode?

But aside from that, I'm pleased. You covered all the configuration options I think I'd want!

Kudos!
Glad you got it working.

The script is not signed... My understanding is that the RemoteSigned execution policy allows you to run your own scripts or scripts signed by a trusted developer. I may have assumed incorrectly that the act of editing my downloaded script to add your settings made the script your own for the purpose of this policy.

EDIT: Alternatively, you could try creating a new text file, pasting my code into it, and saving it as your own script, like 'my_pushover_resize.ps1'.
 
Last edited:
Glad you got it working.

The script is not signed... My understanding is that the RemoteSigned execution policy allows you to run your own scripts or scripts signed by a trusted developer. I may have assumed incorrectly that the act of editing my downloaded script to add your settings, made the script your own for the purpose of this policy.

EDIT: Alternatively, you could try creating a new text file, pasting my code into it, and saving it as your own script, like 'my_pushover_resize.ps1'.

Gotcha. I'll try that. I'm also reading about creating a self signed script. I just don't like the idea of any powershell script being able to run.

I'll post back with my findings.

Thanks again though!
 
@scoob8000 I'm curious what you are getting for execution times with your large alert files.

The screenshot below shows 10 typical events from my script's CSV log file.
For this sample, I'm seeing the following...
TotalMsec ~ 700-1300
ResizeMsec ~ 180-250 ... for resizing ~1200 KB alert jpgs to ~50 KB
PushoMsec ~ 400-1000 ... includes the time to attach the resized image & send the notification

1685031914879.png
 
Last edited:
@scoob8000 I'm curious what you are getting for execution times with your large alert files.

I've only got a couple entries as I only put this on one cam now to test, and I've been fiddling around with the size and quality. The first couple were your default, then a couple at 90 quality, max 1000, and the last couple max 1500 quality 85.

Code:
"2023/05/25_08:55:00","1386.4","157.4","1906.8","289.1","1572.5","D:\BlueIris\Alerts\AtticFront.20230525_085454.321.17-0.jpg"
"2023/05/25_09:23:28","1522.0","158.9","1909.0","323.0","1528.8","D:\BlueIris\Alerts\AtticFront.20230525_092238.43890.17-0.jpg"
"2023/05/25_09:29:15","1375.0","157.5","1169.6","272.0","855.3","D:\BlueIris\Alerts\AtticFront.20230525_092238.391636.17-0.jpg"
"2023/05/25_09:31:18","1526.6","255.9","2197.7","292.7","1856.3","D:\BlueIris\Alerts\AtticFront.20230525_092238.514024.17-0.jpg"
"2023/05/25_09:33:30","1365.2","250.3","1411.0","300.2","1066.3","D:\BlueIris\Alerts\AtticFront.20230525_092238.645956.17-0.jpg"


[EDIT]
I also figured out how to run the powershell without changing the policy for the whole system..

Just add " -ExecutionPolicy Bypass " in front of the -FILE ..... bit.

I strung that all together as a macro, so in the alert I can just put %9.
 
Last edited:
  • Like
Reactions: jaydeel
I've only got a couple entries as I only put this on one cam now to test, and I've been fiddling around with the size and quality. The first couple were your default, then a couple at 90 quality, max 1000, and the last couple max 1500 quality 85.

Code:
"2023/05/25_08:55:00","1386.4","157.4","1906.8","289.1","1572.5","D:\BlueIris\Alerts\AtticFront.20230525_085454.321.17-0.jpg"
"2023/05/25_09:23:28","1522.0","158.9","1909.0","323.0","1528.8","D:\BlueIris\Alerts\AtticFront.20230525_092238.43890.17-0.jpg"
"2023/05/25_09:29:15","1375.0","157.5","1169.6","272.0","855.3","D:\BlueIris\Alerts\AtticFront.20230525_092238.391636.17-0.jpg"
"2023/05/25_09:31:18","1526.6","255.9","2197.7","292.7","1856.3","D:\BlueIris\Alerts\AtticFront.20230525_092238.514024.17-0.jpg"
"2023/05/25_09:33:30","1365.2","250.3","1411.0","300.2","1066.3","D:\BlueIris\Alerts\AtticFront.20230525_092238.645956.17-0.jpg"
Thanks.

It's clear that the Pushover notification prep/send is the dominant term.
Do you notice the ~2 sec delay from a trigger to receiving the notification?

I would be curious to learn how long it takes for the typical Blue Iris 'run a program' action (using curl) to send Pushover notifications with large attachments
I don't yet know of way to measure it. Maybe my script is best way to get insight on this.

I'm currently trying to compare 'PushoMsec' for resized attachments vs fullsized attachments by adjusting the script's user settings as follows
$img_quality = 100
$img_size = 0
(see the comments in the USER SETTING code section)
 
Thanks.

It's clear that the Pushover notification prep/send is the dominant term.
Do you notice the ~2 sec delay from a trigger to receiving the notification?

I would be curious to learn how long it takes for the typical Blue Iris 'run a program' action (using curl) to send Pushover notifications with large attachments
I don't yet know of way to measure it. Maybe my script is best way to get insight on this.

I'm currently trying to compare 'PushoMsec' for resized attachments vs fullsized attachments by adjusting the script's user settings as follows
$img_quality = 100
$img_size = 0
(see the comments in the USER SETTING code section)

There is a little delay. In my testing I'm using an external trigger, and just hitting "trigger now" to test it. Most of the delay is in BI. I don't think it runs the alert action until the red border on the alert list clip goes away. Maybe until it's finished running AI.
 
I also figured out how to run the powershell without changing the policy for the whole system..
Just add " -ExecutionPolicy Bypass " in front of the -FILE ..... bit.
Thanks for this... I've modified post 347 to include this option.
I've also updated the script (V1.3) to expose the active execution policy in the background message.
 
Following up on post #352... this time sending fullsize alert images

The screenshot below shows 10 typical events.
For this sample, I'm seeing a 3-4X increase in the execution time for Pushover send the notification with a fullsize alert image.
Pushover function execution time 'PushoMsec' ~ 1800-2900 (vs 400-1000 for resizing ~1200 KB alert jpgs to ~50 KB)

1685117657045.png


Conclusion:
Pushover notifications might be delivered 1-2 seconds faster by routinely using this script instead of the original curl command option (post #1). And probably much faster if the size of the alert image attachments are approaching the maximum 2500 KB allowed by the Pushover API.

=====
Some readers might notice that the 'ResizeMsec' function execution times in the screenshot are not zero, as might be expected (because we are not actually compressing the file). The reason why is that the code copies the alert image to the folder used by this script. It also touches the timestamp of the file. This appears to take ~100 msec for a 1200 KB file.
 
Last edited:
  • Like
Reactions: jrbeddow
My understanding is that the RemoteSigned execution policy allows you to run your own scripts or scripts signed by a trusted developer. I may have assumed incorrectly that the act of editing my downloaded script to add your settings made the script your own for the purpose of this policy.
I'm quoting myself to provide an update on the mentioned assumption.

My experiment...
0. Checked my current execution policy
1685120285520.png

1. Downloaded the *.zip from post #347.
2. Extracted the script *.ps1 file
3. Tried executing the script (without editing) ... and received the following warnings:
In Windows Terminal (PSVersion 7.3.4)
1685120776815.png

In PowerShell ISE (PSVersion 5.1.19041.2673)...
1685121977360.png

4. Edited the file to modify a user setting, then saved (without renaming).
3. Tried executing it again .... this time it ran without any warnings

So my conclusion is the following.
If you use Powershell's 'RemoteSigned' ExecutionPolicy, then edit a downloaded PowerShell script to add your settings, this is sufficient to make the script your own for the purpose of this policy.
 
Last edited:
Updated Powershell script 'pushover_resize.ps1' (post #347)
Script updated to V1.4
- Changed attachment argument requirement to optional; script now requires only message argument


The script can now be used in any of these modes:
1. no attachment
2. full-size attachment (use settings:
$img_quality = 100, $img_size = 0)
3. custom resized attachment

Why might you want to try this script?
1. To speed up delivery of your Pushover notifications (by reducing the payload sent to the Pushover API).
2. To evaluate the performance of your Pushover notifications under different conditions (by using the script's built-in CSV log file).
 
Last edited:
  • Like
Reactions: jrbeddow
Updated Powershell script 'pushover_resize.ps1' (post #342)
Script updated to V1.4
- Changed attachment argument requirement to optional; script now requires only message argument


The script can now be used in any of these modes:
1. no attachment
2. full-size attachment (use settings:
$img_quality = 100, $img_size = 0)
3. custom resized attachment

Why might you want to try this script?
1. To speed up delivery of your Pushover notifications (by reducing the payload sent to the Pushover API).
2. To evaluate the performance of your Pushover notifications under different conditions (by using the script's built-in CSV log file).
Out of curiosity, and it might be too early to tell, but have you gotten any sense that using this might cut back on the number of "empty" (missing attachment) Pushover messages? I haven't implemented this just yet (and will probably have more questions later when I do), but this would be my primary motivation (along with the potential 1-2 second gain in notification speed).