I want to convert a batch of images, nearly 100, from jpg to png format. How can I do this without renaming them, but instead actually converting the format?
44 Answers
Try these commands,
mogrify -format png /path/*.jpg This will convert all the .jpg files into .png files and saves the converted files in the same directory.
mv /path/*.png ~/Desktop/picThis will moves all the .png files(converted) to the pic directory which resides on the Desktop.
Disclaimer:
If you want to keep the orientation of your image you have to add -auto-orient to the command. You can find out why here. The mogrify command which keeps the orientation would look like this:
mogrify -auto-orient -format png /path/*.jpg 10 Using ImageMagick.
First install imagemagick:
sudo apt-get install imagemagickTry converting just one image at first:
convert image.jpg image.pngNow convert all:
mogrify -format png *.jpgEDIT
You also need to split it into chunks that will fit to avoid hitting the limit of how much you can put on a command line. This should work better:
find -name '*.jpg' -print0 | xargs -0 -r mogrify -format pngThe -print0 and -0 are used to handle spaces in filenames and the -r means don't run mogrify if there's nothing to do.
Source:
EDIT 2Switched png and jpg as per @Glutanimate's comment.
EDIT 3Changed png to jpg in last suggestion.
8Firstly, convert works. You don't need to test it. Secondly, a bash oneliner suits the need:
$ for file in Ground*jpg; do { \ echo "Converting $file to `echo $file|cut -d. -f1`.png" ;\ convert $file `echo $file|cut -d. -f1`.png ; } doneRockin' it auldskewl ;)
Cheers
I know it's been a long time since this question was put but there is one brilliant piece of software that has not been mentioned that I have used a lot.
also known as Phatch. It literally converts anything from anything to anything else in image terms. It had not been updated for a while but now claims to be released for ubuntu 17.10. Give it a try. I'm confident you'll be very happy with it.
1