adrianrdzv
(Adrian Rodriguez)
January 13, 2024, 12:04am
1
I’m trying to resize AND crop a camera snapshot to send it as notification image to my android device. I’m trying to get a 2:1 image: from an original 1280 × 960, a resized to 1024 × 768, and then cropped to 1024 x 512
However, this is not working:
camera:
- platform: proxy
entity_id: camera.timbre_sub
name: timbre_sub_resized
max_image_width: 1024
image_quality: 60
- platform: proxy
entity_id: camera.timbre_sub_resized
mode: crop
name: timbre_sub_cropped
image_top: 256
max_image_height: 512
The image I get in timbre_sub_cropped is basically the resized one: 1024 × 768, the second proxy camera is not doing the crop. Anyone has ideas on why?
adrianrdzv
(Adrian Rodriguez)
January 13, 2024, 2:04am
2
For anyone also struggling with this, after more investigation, seems that the reverse order works: first do the crop then the resize:
camera:
- platform: proxy
entity_id: camera.timbre_sub
name: timbre_sub_cropped
mode: crop
image_top: 320
max_image_height: 1440
image_quality: 60
- platform: proxy
entity_id: camera. timbre_sub_cropped
name: timbre_sub_resized
max_image_width: 1024
Even more interesting, if I change the image_quality
parameter to the resizing action again it doesn’t work:
camera:
- platform: proxy
entity_id: camera.timbre_sub
name: timbre_sub_cropped
mode: crop
image_top: 320
max_image_height: 1440
- platform: proxy
entity_id: camera. timbre_sub_cropped
name: timbre_sub_resized
max_image_width: 1024
image_quality: 60
Hope it helps anyone else.
direx1
(Direx1)
May 22, 2024, 10:49pm
4
Does the proxy produce a new entity Id or just change the existing one? Ideally I’d like to use both images.
hkrob
(Rob)
October 16, 2024, 3:58am
5
I also found crop not to be working in 2024.10.2
My solution is to use a script and a shell command.
The Script:
alias: Doods Crop GarageDoor
sequence:
- action: camera.snapshot
target:
entity_id: camera.camera_front_main
data:
filename: /config/www/doods_garagepersondoor.jpg
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- action: shell_command.doods_crop_garagedoor
metadata: {}
data: {}
description: ""
The shell command:
shell_command:
doods_crop_garagedoor: ffmpeg -y -i /config/www/doods_garagepersondoor.jpg -vf "crop=650:650:102:1182" /config/www/doods_garagepersondoor_cropped.jpg
Then, as I am using doods for image recognition, I had to create a dummy camera as such
camera:
- platform: local_file
file_path: /config/www/doods_garagepersondoor_cropped.jpg
name: doods-garagepersondoor
Hope this helps someone!