tested on: Linux laptop 3.16.0-4-686-pae #1 SMP Debian 3.16.7-ckt20-1+deb8u2 (2016-01-02) i686 GNU/Linux

update: 2019-01: also tested on hostnamectl # Operating System: CentOS Linux 7 (Core) # CPE OS Name: cpe:/o:centos:centos:7 # Architecture: x86-64

if using one core is enough:

# debian/ubuntu:
# update repo
apt-get update;
# centos/redhat
yum update;

# install image manipulation programs -- binaries
# debian/ubuntu
apt-get install imagemagick parallel;

# centos/redhat
yum install parallel openjpeg2.x86_64;

# centos/redhat some more manual work needs to be done
# error: Failed dependencies:
#	libopenjp2.so.7()(64bit) is needed by ImageMagick-libs-7.0.8-24.x86_64

# imagemagick will have to be downloaded manually
wget https://imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-libs-7.0.8-24.x86_64.rpm
wget https://imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-7.0.8-24.x86_64.rpm

# installed manually
# libraries
rpm -Uvh ImageMagick-libs-7.0.8-24.x86_64.rpm
# program
rpm -Uvh ImageMagick-7.0.8-24.x86_64.rpm

# create the script
vim /scripts/png2jpg.sh

#!/bin/bash
# test if path-argument was passed
# if not use current directory
if [ -z "$1" ]
  then
	echo "... no dir was passed using current"
  else

	echo "... changing to directory "$1
	cd $1;
fi

# uses all cores to convert pictures
ls -1 *.png | parallel convert '{}' '{.}.jpg'
# alternative
# for i in *.png ;
# 	do convert "$i" "${i%.*}.jpg" ;
# done
# alternative
# ls -1 *.png | xargs -n 1 bash -c 'convert "$0" "${0%.*}.jpg"'

:wq

# mark it executable
chmod +x /scripts/png2jpg.sh

# run it
/scripts/png2jpg.sh

credits: https://imagemagick.org/

thanks! MagicWizard!

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin