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 Morgify tool (from the same command line when in imagemagick). Keep in mind that this overwrites the old images. The command is:
|
|||||||||||||||
|
|
There is no reason to install ImageMagick if it won't ever be used again. The linux convert command, as pointed out by Jeffrey, is enough. To avoid that double extension problem this is what the bash code should look like:
|
|||||||||||||
|
|
The actual "
|
||||
|
|
|
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. |
|||
|
|
|
my quick solution
|
|||||
|
|
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...)
The final command that I use looks like this for refrence. I use
|
|||||||||||||
|