Lich-Corals / linux-file-converter-addon

Convert between various image, audio and video formats.
GNU General Public License v3.0
15 stars 6 forks source link

New Nemo converter cant convert to jxl or avif. #34

Closed Username23453 closed 6 months ago

Lich-Corals commented 7 months ago

Please provide more information about your issue, I can't reproduce your issue. Please also start the script manually in the terminal by running these commands:

cd ~/.local/share/nemo/actions/

python nautilus-fileconverter.py /path/to/example/image/file.png

If there are any errors, they may help to identify the issue.

Username23453 commented 7 months ago

@Lich-Corals , i did that and I get an error

"WARNING(Nautilus-file-converter)(005): Double script installation detected. View https://github.com/Lich-Corals/linux-file-converter-addon/blob/main/markdown/errors-and-warnings.md for more information.
Args: ['/home/userzzz/Pictures/Untitled Folder/il_fullxfull.3969746407_l1bj.avif'] 
Path:/home/userzzz/.local/share/nemo/actions
"

And when I do the above command the box pops up but wont drop down or let me choose what I want to do. See screenshot:

image

I do have more than one converter script in my /home/user/.local/share/nemo/actions directory though.

image

Lich-Corals commented 7 months ago

The warning you get seems to be a thing I just didn't think about when I ported the script; it shouldn't be a problem for the script. All that it tells you is, that there is a root installation of the Nautilus version.

I have an idea what it might be, please open the properties of the image you want to convert and tell me what the "Type" value is. There should be something like "image/avif" in it, that's what I need to know. And, just for my understanding, does it show no options in the dropdown, or just not the ones you need?

Username23453 commented 7 months ago

The "type" for both jxl and avif is: "Binary (application/octet-stream)"

And the dropdown query box doesnt even dropdown or list anything at all for either jxl or avif. Its like the screenshot above, no way to proceed with it.

Lich-Corals commented 7 months ago

Okay, I had a problem with this type before. Probably the only fix is, to uncomment line 140 of the script. It currently looks like this:

#                      'application/octet-stream', <-- Didn't make any problems in nautilus, but Nemo takes all files in it (.zip, .doc, .pdf, etc.) instead of only the image types.

And it should look like this:

                      'application/octet-stream',

It may be a problem if the formatting is not perfectly inline with the other formats:

# It has to look like this...
                      [...]
                      'image/vnd.net-fpx',
                      'application/octet-stream',
                      'windows/metafile',
                      [...]
# ...and not like this:
                      [...]
                      'image/vnd.net-fpx',
                     'application/octet-stream',
                      'windows/metafile',
                      [...]

There is one problem with uncommenting it: It will enable the context menu for a lot of files, which can't be converted, because the mimetype 'application/octet-stream' includes files like .zip, .doc and .pdf.

I will have a look at how to solve it in a better way later, but I think it should work for now to just uncomment it.

Username23453 commented 7 months ago

I did what you said, but it still dont work. I edited "nautilus-fileconverter.py" file.

And now it looks like this. image

Lich-Corals commented 7 months ago

It's important that you put a comma at the end of the line; like this:

'application/octet-stream',
Username23453 commented 7 months ago

@Lich-Corals, thanks, unfortunately it still doesnt work, and now it appears I cant do webp anymore either.

I dont think it should matter if I have multiple scripts in nemo? image

Lich-Corals commented 7 months ago

I don't think it's a problem with the other scripts, but it won't hurt to try it without those.

I will take a closer look at the problem in the next days, I don't have much time right now.

Lich-Corals commented 7 months ago

I thought about it a bit more, I'm not sure, why it doesn't work for your files, but I think it is a problem with the mime type. Could you upload an image, which should work but doesn't, so I can test my solution? I couldn't reproduce this situation so far.

Username23453 commented 7 months ago

extract this zip file, there are four different image types and none of them work with your tool.

zip.zip

Lich-Corals commented 7 months ago

The problem should be fixed now. I found out, that the script detected a different mimetype for some images, which wasn't in the database. I changed the determination method for mimetypes in the Nemo adaption, this should hopefully solve your issue.

Don't forget to update the script and dependencies before testing the script. (See this page to see what's needed.)

Username23453 commented 7 months ago

I updated the scripts, I also installed "python-magic", & "jxlpy". I also "chmod +x" the new .py file.

But now when I click "Convert to..." for ANY file, it doesnt do anything, doesnt give me the prompt at all. So something is malfunctioning.

Thats for nemo, I tried Nautilus and Nautilus is working perfect and will convert avif, webp, jxl, and heic.

Lich-Corals commented 7 months ago

I will write a debug version of the script as soon as possible. Could you give me the endings and mimetypes of the files, which don't work for you? I could convert every but one image you sent me before, the others worked without any problems.

Username23453 commented 7 months ago

@Lich-Corals , i dont think the endings or mimetypes really matters, as I'm saying, its something much more fundamental. Something i guess you changed since your last version, that makes it completely not work at all for nemo.

Lich-Corals commented 7 months ago

Sorry that it took me so long, I finally finished a debug version for you. I attached the file to the next command; just overwrite the old one and run Nemo using NEMO_DEBUG=Actions nemo --debug in your terminal app. It should spit a lot of debug information about what exactly happens, it should also show any python errors or Nemo errors. Just have a look at the output after trying to convert a few files; you can also send me the output, and I'll look for any error messages or the point where the script stops working.

Lich-Corals commented 7 months ago

Here the file in a zip: nautilus-fileconverter.zip

Username23453 commented 7 months ago

@Lich-Corals , its only one .py file? why did you zip it? haha :)

Username23453 commented 7 months ago

Here's the debug log results, it appears its looking for "magic" and it should be "python-magic" instead?

TXT.txt

Lich-Corals commented 7 months ago

It is a ModuleNotFoundError, which means that the script wasn't able to find your python-magic installation. I don't have much experience with this issue, but I can provide a few ideas what could help with this.

pip install python-magic


You could also try to install the apt package, as long as this is your package manager:
```bash
sudo apt install libmagic1

If you've done this, and it's still not working, you could go to the "Running the tests" Section of this page and see if those tests return any useful information. I haven't tried those, but I'd assume that the official tests should work. If all of this doesn't solve the problem, I'd recommend opening an issue at python-magic's GitHub page, although I don't know how active they are. Another option would be to ask a question on stack overflow, there might be some people who know more about this issue than I do.

I hope we'll get your issue fixed soon; for now, you can still use the latest version without the magic library, which should work better, when not ideal for some file types.

I'm still looking for a better solution than the magic library, but it seems to be a pretty hard problem to determine the mime type without tons of additional libraries, which cause new issues.

Lich-Corals commented 7 months ago

@Lich-Corals , its only one .py file? why did you zip it? haha :)

GitHub doesn't want me to upload a python file in a command, so I have to compress it before uploading it. :D

Username23453 commented 7 months ago

Thanks for your replies, and I had no idea github wont allow .py uploads, thats weird. haha. Thanks for explaining!

1.) I thought I had python-magic installed, but I guess I didnt. So I just installed it, now the menu comes up now.

2.) Your tool works for .heic and .webp, but it doesnt work for .jxl or .avif, no "Convert to" menu comes up at all or anything. Even though "pillow-avif-plugin" AND "jxlpy" are both installed. But if you could tell me how to direct your script at these .jxl and avif files in my terminal and in your debug mode so we can diagnose, please tell me how to do this.

3.) Also, when the convert to menu does come up, it is weird now and the column that pops down with all the convert options, it all works, but the top of it is blank and goes up infinitely, and also takes up a substantial part of the column and screenspace, its a malfunction. See screenshot.

20240412_1607132024-04-12-17-02-22

-Thanks

Lich-Corals commented 7 months ago

I'm glad it was so easy to fix.

To run the script manually, you can just run it with the file paths as arguments:

python path/to/script.py /path/to/file.any

I'm not sure if this will return much useful information, because I'd expect it to be a mimetype issue. You could first try to uncomment the 'application/octet-stream' line again, as we did before. Don't forget to leave the comma behind it, otherwise it would return an error.

The problem with the infinite drop-down is there, because there are too many formats it. It's a GTK Problem. You could disable wallpaper and square formats in the config to only get the normal formats; this should fix the issue for now. I'm working on a better solution, for example two additional drop-downs for the special formats.

Username23453 commented 7 months ago

@Lich-Corals , I uncommented the 'application/octet-stream' and now everything works, avif, webp, jxl,and heic, and also there isnt an infinite drop down list anymore, theres still a lot of white/blank slots on top, but not nearly as many as previous. :)

Lich-Corals commented 7 months ago

I'm glad we finally solved it. I will probably add a new option to the script in near future, which will allow to add octet-stream to the read formats. Please note that your script change will be reset with every update until I add it as a setting; if I do so, I'll write it into the patch notes, then you just have to enable the setting and it will persist with updates.

If your issue is solved, please close the issue; in not, feel free to to continue the conversation.

Username23453 commented 7 months ago

Thanks for all your help! :)

One more thing I want to suggest, and I've mentioned this before I think is that when I click "Convert to" sometimes the click on my touchpad becomes a double click accidentally and what immediately pops up after the Convert to is a PNG, so it converts without me wanting it to. The transition is too quick. The problem is that the PNG option pops up in same exact place as where my cursor was. Can you add a non working slot at the top? where PNG is? Like one that says "Options"? And that doesnt do anything when clicked? -Thanks!

image

Lich-Corals commented 7 months ago

Thanks for the suggestion, I will add this to my fix list and add it as a new option in the next patch. This should be a really quick change.

Username23453 commented 6 months ago

@Lich-Corals , Your new script, 1.2.10 doesnt do jxl or avif. I even tried to add the following to try to fix it, but it didnt help, but otherwise, your new script is great, I put the below in the correct spots but still doesnt work:

'application/octet-stream', #<-- Didn't make any problems in nautilus, but Nemo takes all files in it (.zip, .doc, .pdf, etc.) instead of only the image types.

if "application/octet-stream" in READ_FORMATS_IMAGE:
    print(f"NFC43-DEBUG: application/octec-stream is in READ_FORMATS_IMAGE")
Lich-Corals commented 6 months ago

Are you sure you enabled the convertFromOctetStream setting like described here?

Username23453 commented 6 months ago

Thank you. I had no idea you even came out with a new release until today, I just happened to check for updates which i normally never do for anything. And your release page for 1.2.10 doesnt mention anything about a Configuration.json file, so i didnt know to look. But yep, i followed all the instructions and it all works beautifully, and you did a great job with the "dummy option". :) Thanks again!

Also, check this tool out, if I havent already showed you, its got a whole suite of right click options. Although I prefer yours for many reasons. https://github.com/cfgnunes/nautilus-scripts/issues/19

Lich-Corals commented 6 months ago

I'm glad it was easy to fix this time. I actually know this tool you linked; the creator of it asked for information about my script a few weeks ago, but thanks for mentioning it anyway. :D