For file sharing I prefer something like Send which is a fork of the now discontinued Firefox Send. It's fully open source and can be self-hosted, and it also supports use through the command line. But for plain text files I'd much rather use something simpler like the links I already shared; just preference.
Yes, the script itself will work with any format (well, the most popular ones anyway) and can run on the command line normally, but to use it in the context menu you'll have to create a separate nemo action file for each use case.
The -f or --formats flag is used to specify the desired output format or formats you want to convert to. For example use -f .png .webp .avif to convert to all those three in one go.
Use -o or --output-dir to specify the location where you want to save the converted images. By default it will use the same directory as the original images.
Inside the nemo_action file make sure to change "Exec" to point to the location to the script in your computer. And the "Extensions" field to specify which under which files will the option appear. At the moment however the script will convert from .jpg, .jpeg, .png, .webp and .avif.
Thanks I know about https://send.vis.ee actually, just never got around to using it. I was content with the other one's i've been using, but I have no issue with using it. And thanks for the advice about it.
2.) I've got it all set up and almost working however its not producing, outputting anything.
What should this look like if I want it to output into the same folder that the images I want converted are in? I need to know what to put for "%p" & "%F"?
Thanks, i didnt do that, I've done chmod stuff very similar to what we're doing now before and I often forget to do chmod. However, even after just now doing it, it still doesnt work.
Here is what my .nemo_action file looks like below, also based on my notes from previous similar projects, I've discovered that putting bash or python or python3 after "Exec=" will fix the problem, but even after doing this, it didnt help this time.
For example, Exec=python '/home/user/Scripts,DONT MOVE/made by zorin user zenzen, convert.py' -f .png -o "%p" "%F"
Also no error log is being created.
[Nemo Action]
Active=true
Name=Conv to PNG
Comment=Exactly what it sounds like
Exec='/home/user/Scripts,DONT MOVE/made by zorin user zenzen, convert.py' -f .png -o "%p" "%F"
Selection=all
Extensions=jpg;jpeg;png;avif;webp;bmp;tif;tiff;gif;
@Aravisian , So i by chance happened to be looking into my home user directory, /home/user and I found the deb file that "alien" converted from the rpm. Alien apparently converted it to deb and didnt tell me it did successfully OR where it outputted it to.
@zenzen , UPDATE. When I start Nemo using terminal, rather than left click. It will show me error messages in my terminal in regards to your script. Here's the error messages I'm getting.
from: can't read /var/mail/PIL
from: can't read /var/mail/concurrent.futures
from: can't read /var/mail/pathlib
from: can't read /var/mail/typing
import-im6.q16: attempt to perform an operation not allowed by the security policy `PS' @ error/constitute.c/IsCoderAuthorized/413.
import-im6.q16: attempt to perform an operation not allowed by the security policy `PS' @ error/constitute.c/IsCoderAuthorized/413.
import-im6.q16: attempt to perform an operation not allowed by the security policy `PS' @ error/constitute.c/IsCoderAuthorized/413.
import-im6.q16: attempt to perform an operation not allowed by the security policy `PS' @ error/constitute.c/IsCoderAuthorized/413.
/home/user/Scripts,DONT MOVE/made by zorin user zenzen, convert.py: 10: ALPHA_CHANNEL_UNSUPPORTED: not found
/home/user/Scripts,DONT MOVE/made by zorin user zenzen, convert.py: 11: FILE_NOT_FOUND_ERR_CODE: not found
/home/user/Scripts,DONT MOVE/made by zorin user zenzen, convert.py: 12: VALID_FORMATS: not found
/home/user/Scripts,DONT MOVE/made by zorin user zenzen, convert.py: 14: Syntax error: "(" unexpected
@zenzen , 2ND UPDATE, I realized i didnt have Pillow pillow-avif-plugin installed. But still nothing happens, i actually made progress though when I put python3 after "Exec=" , but then the terminal seems to tell me i need to install
pip3 install Pillow pillow-avif-pluginno image input
But when I try to do that I get this:
ERROR: Could not find a version that satisfies the requirement pillow-avif-pluginno (from versions: none)
ERROR: No matching distribution found for pillow-avif-pluginno
I don't recommend using spaces or any non-alphanumeric characters, other than underscores, hyphens and forward slashes, when specifying file locations. It's just screams trouble all around. One thing you can do to keep things organized is place the Python script next to the nemo_action file, and reference it like this:
[Nemo Action]
Active=true
Name=Conv to PNG
Comment=Exactly what it sounds like
Exec=<convert.py -f .png -o "%p" "%F">
Selection=all
Extensions=jpg;jpeg;png;avif;webp;bmp;tif;tiff;gif;
The angle brackets are a special syntax for Nemo that tells it to look in the same folder as the action.
Looking at the script I shared again, I forgot to add one important line. Edit the script in your computer and add the following at the very beginning (make sure you leave an empty line, between this and the rest of the code):
#!/usr/bin/python3
This could be solved, as you suggested, by providing this in the Exec line... but because of the Nemo special syntax this won't work (or maybe there's a way but this is much cleaner anyway).
And finally, you should know that I only tested this script with these extensions: jpg, jpeg, png, webp, avif. Originally I wrote this script for myself and those are the only formats I use. Also, there's a guard to prevent the script to attempt to process any other file types. If you open the script file with a text editor and want to expand on that make sure to add those in the VALID_FORMATS variable.
As for the installation I suspect you need to install pip first, if you haven't done so already. Just in case, you should run these two lines (one at the time):
As most of you folks know I am a long time newbie when it comes to Linux so please bare with me .... I have Image Magic loaded from the terminal and found this on the Ubuntu 22.4 website ...... it says to convert xxx file to xxx file do this ...... but were do I do this ????? .....and will this convert all avif files to png or do I need to do this for every file ????? ....
Convert an Image Format with ImageMagick on Ubuntu
ImageMagick can also convert an image from one format to another. For example, you can use the following command to convert a JPG image to PNG.
convert input.jpg output.png
It obviously doesn't work in the terminal cause I tried it ..... " convert input.avif output.png "
@zenzen , I've got everything installed, I double checked to make sure. But your tool still doesnt work. I also made sure to chmod u+x the .py.
I even tried the "<convert.py -f .png -o "%p" "%F">" method.
When i try your tool now, i get an error in the terminal:
ModuleNotFoundError: No module named 'pillow_avif'
[h264 @ 0x559cfaf54400] co located POCs unavailable
Traceback (most recent call last):
File "/home/user/.local/share/nemo/actions/convert.py", line 7, in <module>
import pillow_avif
ModuleNotFoundError: No module named 'pillow_avif'
And this is what happens when I do this:
pip3 install Pillow pillow-avif-plugin
Requirement already satisfied: Pillow in ./anaconda3/lib/python3.11/site-packages (9.4.0)
Requirement already satisfied: pillow-avif-plugin in ./anaconda3/lib/python3.11/site-packages (1.4.3)
You are using Anaconda as a package manger for Python. This won't work unless you install these packages where they are globally accessible, as otherwise Nemo can't find them.
@zenzen , did what you said, multiple different ways, none worked:
(base) user@user:~$ pip3 install --root $user/.local/share/nemo/actions/<action_name> Pillow pillow-avif-plugin
bash: action_name: No such file or directory
(base) user@user:~$ pip3 install --root user/.local/share/nemo/actions/<action_name> Pillow pillow-avif-plugin
bash: action_name: No such file or directory
(base) userzzz@user:~$ pip3 install --root userzzz/.local/share/nemo/actions/<convert.py> Pillow pillow-avif-plugin
bash: convert.py: No such file or directory
(base) userzzz@user:~$ pip3 install --root $userzzz/.local/share/nemo/actions/<convert.py> Pillow pillow-avif-plugin
bash: convert.py: No such file or directory
You are supposed to replace <action_name> with the name of the file that you created.
Also, using a virtual environment will prevent this from working entirely for the reasons that I mentioned in my previous post: Nemo needs to be able to read these scripts.
Probably best to start over, here's a summary of what you need:
A file that defines the nemo action placed under /home/<your_username>/.local/share/nemo/actions. The name of the file doesn't matter but it needs to have an extension of .nemo_action e.g.: convert.nemo_action.
The contents of the file should look something like:
[Nemo Action]
Active=true
Name=Conv to PNG
Comment=Exactly what it sounds like
Exec=<convert.py -f .png -o "%p" "%F">
Selection=all
Extensions=jpg;jpeg;png;avif;webp;bmp;tif;tiff;gif;
In this case, because the "Exec" option from snippet above used angle brackets, the convert.py script needs to be placed in the same folder as the nemo action file.
The Python script needs a few dependencies to run. Those dependencies must be installed globally i.e., not in a virtual environment. You can install them with:
@zenzen , I made some progress. And I'd like to uninstall "Anaconda" but its too difficult to. Very complex and dangerous, could screw up my OS. Ironically Installing it was not hard i recall, and i didnt know it would be problematic.
I also just now tried it after deactivating conda. "conda deactivate"
Here's my nemo action filepath: /home/userzzz/.local/share/nemo/actions/123.nemo_action
here's my new terminal attempts:
userzzz@user:~$ pip3 install --root $HOME/.local/share/nemo/actions/123.nemo_action Pillow pillow-avif-plugin
Requirement already satisfied: Pillow in ./.local/lib/python3.8/site-packages (10.0.0)
Collecting pillow-avif-plugin
Obtaining dependency information for pillow-avif-plugin from https://files.pythonhosted.org/packages/8d/bd/c5b225e0abbad17cd4de12ad5704b69d2634411457e4172d9c032fcfd1f8/pillow_avif_plugin-1.4.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
Downloading pillow_avif_plugin-1.4.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.7 kB)
Downloading pillow_avif_plugin-1.4.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.0/8.0 MB 1.0 MB/s eta 0:00:00
DEPRECATION: omegaconf 2.0.6 has a non-standard dependency specifier PyYAML>=5.1.*. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of omegaconf or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063
Installing collected packages: pillow-avif-plugin
ERROR: Could not install packages due to an OSError: [Errno 20] Not a directory: '/home/userzzz/.local/share/nemo/actions/123.nemo_action/usr'
[notice] A new release of pip is available: 23.2 -> 24.0
[notice] To update, run: python3 -m pip install --upgrade pip
ls -l $HOME/.local/share/nemo/actions/anaconda/bin
Does this show any files or an error saying it doesn't exist? If it shows files, go to the Python script and change the very first line, and try again:
@zenzen , here's what i get, what should i do now?
(base) userzzz@user:~$ ls -l $HOME/.local/share/nemo/actions/anaconda/bin
ls: cannot access '/home/userzzz/.local/share/nemo/actions/anaconda/bin': No such file or directory
In that case it's back to the original plan, but you have to not use a virtual environment when installing the Python packages. When you open a terminal, do you already see that (base) at the prompt? Try to run deactivate. If it goes away, then try to install the packages normally, without the --root flag.
I have to ask... did you install Anaconda because of ChatGPT?
2.) I cant remember why I installed anaconda, I've done a lot on my OS in the past year, I'm new to linux. I think I might've been trying to install something from github. And it required conda. Or if chatgpt was involved, maybe chatgpt thought I should install anaconda.
You dont sound very optimistic of chatgpt, LoL. But I dont think you understand that chatgpt works much better if you feed it linux & python pdf's and also if you actually use the paid versions of chatgpt/A.I. Which I havent done either really.
All right, good. So let's go back to installing the dependencies. There's no need to specify the location of the root directory to install them, as that was an attempt to work around the virtual environment. This should do it now:
pip3 install Pillow pillow-avif-plugin
Before you actually run this command, it may be worth checking the contents of the nemo actions folder just to make sure there aren't any additional files from previous attempts. Remember: you only really need the abc.nemo_action file and the Python script.
ChatGPT is just a tool. It performs only as good as your ability to express the problem and understanding the given solution. Without this ability, it really is not much different than blindly copying and pasting code or terminal commands from random strangers online.
Even with the best of intentions, those strangers may be unaware of the current state of your computer, due to prior modifications that you've made to your system, and recommend taking steps that can result in loss of data. Even in an optimistic scenario, everyone's time and effort is wasted chasing ghosts, which is exactly what we're going through right now.
Funnily enough, I ran into this recently that sums it up nicely: