Does anyone know a good way to batch-convert a bunch of PNGs into JPGs in linux? (I'm using Ubuntu).
A png2jpg binary that I could just drop into a shell script would be ideal.
Does anyone know a good way to batch-convert a bunch of PNGs into JPGs in linux? (I'm using Ubuntu). A png2jpg binary that I could just drop into a shell script would be ideal. |
||||
|
Your best bet would be to use Imagemagick I am not an expert in the actual usage, but I know you can pretty much do anything image related with this! An example is:
and it will keep the original as well as creating the converted image. As for batch. I think you need to use the Mogrify tool (from the same command line when in imagemagick). Keep in mind that this overwrites the old images. The command is:
|
|||||||||||||||||||||
|
The
|
|||||||||||||
|
I have a couple more solutions. The simplest solution is like most already posted. A simple bash for loop.
For some reason I tend to avoid loops in bash so here is a more unixy xargs approach, using bash for the name-mangling.
The one I use. It uses GNU Parallel to run multiple jobs at once, giving you a performance boost. It is installed by default on many systems and is almost definitely in your repo (it is a good program to have around).
The number of jobs defaults to the number of processes you have. I found better CPU usage using 3 jobs on my dual-core system.
And if you want some stats (an ETA, jobs completed, average time per job...)
There is also an alternative syntax if you are using GNU Parallel.
And a similar syntax for some other versions (including debian).
|
|||||||||||||||||||||
|
The actual "
|
||||
|
my quick solution
|
|||||||||||||||||
|
For batch processing:
You will end up with file names like image1.png.jpg though. This will work in bash, and maybe bourne. I don't know about other shells, but the only difference would likely be the loop syntax. |
|||
|
|
|||
|