Need a scripting wiz for a Parallel WEBP conversion command problem?

Message
Author
User avatar
handy
Posts: 614
Joined: Mon Apr 23, 2018 2:00 pm

Need a scripting wiz for a Parallel WEBP conversion command problem?

#1 Post by handy »

Hi there. :)
Since webp came out I've been using a clumsy method to convert the files to png format, one at a time. I always have to manually rename them. I do all this inside of the Worker filemanager where I have a button setup with the following command:

Code: Select all

dwebp {f} -o output.png
This method takes the <filename>.webp data & makes a copy of the image in png format, but named output.png . Which I obviously have to manually rename from "output" to the original or other desired filename.

Now I found some info on the web, & the following command line, which uses the Parallel software package (for speed), & gives me the output <NO name>.png

Code: Select all

parallel dwebp {} -o {.}.png ::: *.webp
Could someone please correct the above command string so that it also transfers the original name of the file to the new png file?
That would be SO helpful. :)

Also, I have this string which is supposed to do the content of nested sub-directories, though I think it is likely not correct either:

Code: Select all

find . -name "*.jpg" -print0 | parallel -0 dwebp {} -o {.}.png
Thanks for looking.
MSI: MAG B560 TORP', i5, RAM 16GB, GTX 1070 Ti 12GB, M2 238GB + USB, MX-23 Fb to Openbx
Lenovo: Ideapad 520S, i5, RAM 8GB, GPU i620, HDD 1TB, MX-23 Fb - Openbx
Clevo: P150SM-A, i7, RAM 16GB, nVidia 8600, 2x 1TB HDD & M.2 256 GB, MX-23 Fb - Openbx

User avatar
CharlesV
Global Moderator
Posts: 7722
Joined: Sun Jul 07, 2019 5:11 pm

Re: Need a scripting wiz for a Parallel WEBP conversion command problem?

#2 Post by CharlesV »

The simplest method I know of if al files are in one folder, is to run this in that folder.

mogrify -format png *.webp
*QSI = Quick System Info from menu (Copy for Forum)
*MXPI = MX Package Installer
*Please check the solved checkbox on the post that solved it.
*Linux -This is the way!

User avatar
handy
Posts: 614
Joined: Mon Apr 23, 2018 2:00 pm

Re: Need a scripting wiz for a Parallel WEBP conversion command problem?

#3 Post by handy »

CharlesV wrote: Sun Jan 07, 2024 9:50 pm The simplest method I know of if al files are in one folder, is to run this in that folder.

mogrify -format png *.webp
Thank you Charles V - Holy Roman Emperor, King of Spain and Duke of Burgundy. No wonder you gained such titles, you are obviously a man of great practical knowledge & diplomacy.

Which is my long way of saying much appreciated. your method works really well, & it was really fast doing multiple files in a directory after I put the string into button on Worker. :D

I won't mark the thread solved just yet though, as I really would like to see how the command lines look when they are made to work properly. ;)
MSI: MAG B560 TORP', i5, RAM 16GB, GTX 1070 Ti 12GB, M2 238GB + USB, MX-23 Fb to Openbx
Lenovo: Ideapad 520S, i5, RAM 8GB, GPU i620, HDD 1TB, MX-23 Fb - Openbx
Clevo: P150SM-A, i7, RAM 16GB, nVidia 8600, 2x 1TB HDD & M.2 256 GB, MX-23 Fb - Openbx

User avatar
handy
Posts: 614
Joined: Mon Apr 23, 2018 2:00 pm

Re: Need a scripting wiz for a Parallel WEBP conversion command problem?

#4 Post by handy »

I just had a look at the mogrify man page. It is really something else. I was unaware of its existence prior to your post CV.
MSI: MAG B560 TORP', i5, RAM 16GB, GTX 1070 Ti 12GB, M2 238GB + USB, MX-23 Fb to Openbx
Lenovo: Ideapad 520S, i5, RAM 8GB, GPU i620, HDD 1TB, MX-23 Fb - Openbx
Clevo: P150SM-A, i7, RAM 16GB, nVidia 8600, 2x 1TB HDD & M.2 256 GB, MX-23 Fb - Openbx

User avatar
CharlesV
Global Moderator
Posts: 7722
Joined: Sun Jul 07, 2019 5:11 pm

Re: Need a scripting wiz for a Parallel WEBP conversion command problem?

#5 Post by CharlesV »

lol... very glad you like it - it is rather quite the interesting command!
*QSI = Quick System Info from menu (Copy for Forum)
*MXPI = MX Package Installer
*Please check the solved checkbox on the post that solved it.
*Linux -This is the way!

User avatar
i_ri
Posts: 1112
Joined: Tue Jun 30, 2015 12:26 am

Re: Need a scripting wiz for a Parallel WEBP conversion command problem?

#6 Post by i_ri »

hello handy and CharlesV and everyone
because you are rather a console purist, you may get a grin from this. Using CharlesV' command: (thanks CharlesV)

Code: Select all

yad --text=" drop image \n create png " --dnd|sed 's/^......./mogrify\ -format png\ /e'
The manual indicates that convert creates a new, second image or mogrify changes a file in-place; the drop box creates a new, second png:image with mogrify; what do you think of that output png outcome?
drop an image format file.

User avatar
i_ri
Posts: 1112
Joined: Tue Jun 30, 2015 12:26 am

Re: Need a scripting wiz for a Parallel WEBP conversion command problem?

#7 Post by i_ri »

Code: Select all

ls *.webp | parallel mogrify -format png {} {.}.png
from example page Using CharlesV' command (?)
https://www.gnu.org/software/parallel/p ... mples.html

Code: Select all

ls *.webp | parallel dwebp -quiet -mt {} -o {.}.png
Last edited by i_ri on Mon Jan 08, 2024 11:40 pm, edited 1 time in total.

User avatar
DukeComposed
Posts: 1462
Joined: Thu Mar 16, 2023 1:57 pm

Re: Need a scripting wiz for a Parallel WEBP conversion command problem?

#8 Post by DukeComposed »

handy wrote: Sun Jan 07, 2024 8:49 pm Now I found some info on the web, & the following command line, which uses the Parallel software package (for speed)
Custom parallelization tools may not be necessary. xargs supports a -P argument, which allows multiple concurrent processes. From "man xargs":
Some commands can usefully be executed in parallel too; see the -P option.

[snip]

-P max-procs, --max-procs=max-procs
Run up to max-procs processes at a time; the default is 1. If max-procs is 0,
xargs will run as many processes as possible at a time. Use the -n option or the
-L option with -P; otherwise chances are that only one exec will be done.
You could pipe the output of find to xargs -P and it should produce a similar workflow right out of the box.

User avatar
handy
Posts: 614
Joined: Mon Apr 23, 2018 2:00 pm

Re: Need a scripting wiz for a Parallel WEBP conversion command problem?

#9 Post by handy »

:clap: Ah! Now I know what a slow old bastard like me needs to try & get my brain's cpu speed up -- max-procs max procs max procs! :D

My thanks to you all, I'll check out all of this very interesting input & see what wonders manifest.

It really is amazing how many ways to skin that poor cat there are. People just keep on finding different ways... It really does seem to be one of humanities core strengths.
MSI: MAG B560 TORP', i5, RAM 16GB, GTX 1070 Ti 12GB, M2 238GB + USB, MX-23 Fb to Openbx
Lenovo: Ideapad 520S, i5, RAM 8GB, GPU i620, HDD 1TB, MX-23 Fb - Openbx
Clevo: P150SM-A, i7, RAM 16GB, nVidia 8600, 2x 1TB HDD & M.2 256 GB, MX-23 Fb - Openbx

User avatar
i_ri
Posts: 1112
Joined: Tue Jun 30, 2015 12:26 am

Re: Need a scripting wiz for a Parallel WEBP conversion command problem?

#10 Post by i_ri »

do be careful with the commands that will overwrite a png file; keep existing png images out of harms way ..

Post Reply

Return to “General”