![]() ![]() This is not a hard number, just a number that I chose and worked well. The next step it will reduce the JPEG compression to 80. In this case it will make sure that neither pixel dimension is greater than 1000. Just because its 1000×1000 pixels does not mean it will change the aspect ratio. The first step is for ImageMagick to change the size of the picture with the transform function. If the file is not in the output folder, its time for ImageMagick to do its work. ![]() If it is already in the output folder, it will bypass it and move to the next file. If it is a picture, it will check if it is already in the output folder. Then, for each file it will check if it is a picture. Using the glob function in the Path library, it will look in all directories and folders for all files. Next, because my camera will output JPG file types, and my phone will output jpg file types I have the program searching for both and writing them as jpg for all. Any folder structure that is placed in the input folder will be copied over to the output, along with the modified pictures. Inside the same folder is and Input and an Output folder. I have the base directory of where this file is located. Now to explain a bit of this hodge-podge of code. Result = n(command, capture_output = True) Img.save(filename = ((output_folder/picture).with_suffix('.jpg'))) Path(PurePath(output_file).parent).mkdir(parents = True, If output_file.with_suffix('.jpg').exists():Įlif not any(x = picture.suffix for x in filetypes): Output_folder = current_directory / 'output' Input_folder = current_directory / 'input' Raise FileNotFoundError('No input folder') If not Path.exists(current_directory / 'input'): '''Read current directory for input folder''' Going with that, all of the Azure configs are saved in ruploader_conf. import argparseįor some reason I don’t remember, I called this program ruploader. Just a few imports to kick off the start of the code. Will need both the OS program and the Python binding. Lastly, need the ImageMagick processing program. Using the OS agnostic properties of Python 3, I am willing to bet it will work on either. Using Azure Storage CLI, do an RSYNC with the output folder and the remote blob container in the Storage Accountįor my setup, my laptop is setup with Fedora, and my workstation is set up with ArchLinux.If they do not exist, convert using ImageMagick for smaller and more compressed pictures. ![]() Search the output directory to see if they exist.Sounds like the perfect time to put Python to work and automate it. No matter what, it takes for ever and take too many clicks. Or you can open it in paint and resize it. It seems like there are pages online that you upload an image and it returns a smaller photo. usr/bin/convert -loop 0 -delay 50 /config//config/There is another issue if you are editing this file in windows, and I guess it is your case based on your error: You need to remove the char(13) “Enter key” because Linux only uses char(10) for a new line.One thing that I hate is resizing photos. ![]() Snapshot_cam_gif: "python3 /config/scripts/cam-gif.py"Īlso, you can change the script to reinstall imagemagick, if it gets uninstalled by a home assistant update, as it happens on HassOS. X = subprocess.check_output(cmd, shell=True) Try this, make a wrapper python program, to call the cam-gif.sh script.īased on the previous example, create a python file: cam-gif.py like this: import subprocess Looks like maybe a path or permissions issue? Without #!/bin/bash in the script: 18:27:59 DEBUG (MainThread) Stderr of command: `/config/cache/test.sh`, return code: 127:ī'/config/cache/test.sh: line 1: convert: not found\n' With #!/bin/bash in the script: 18:41:35 DEBUG (MainThread) Stderr of command: `/config/cache/test.sh`, return code: 127:ī'/bin/sh: /config/cache/test.sh: not found\n' I simplified the script to just run ‘convert -help’ and it still fails the same way: However when I try to run the ‘convert’ script it fails with a return code of 127. I have several other shell_commands that are working fine. I am struggling however, with the shell_commands part. gif was created and was able to be sent via e-mail (and Google Hangouts!) without issue. sh script and ran it from the SSH terminal without issue. With imagemagick installed, then you call in the scripts, commands to create an animated gif with the images from your cameras…Ĭonvert -loop 0 -delay 100 /config//config/Command to turn the file executable: chmod x cam-gif.shĬreate in shell_commands: snapshot_cam_gif: '/config/'/config/- service: you for this info! I was able to SSH into my Hass.io instance and install Imagemaick. Then execute the command to install Imagemagick: apk add -update imagemagick First you have to install SSH server on Hass.IO ADD-ON STORE, and log on with to it with a SSH client like PuTTY. ![]()
0 Comments
Leave a Reply. |