Tired of finding tools to convert the latest set of photographs which you lately shot ? Yes, while photography is fun converting the pictures into different formats can not be so fun at times. And that is why in this post we are going to share with you a script which converts images into multiple extension and that too as a batch process.
This script lets you convert multiple images with one extension like .jpg to .png and many other extensions.
Since the conversion process is time consuming so in this post sam2p has been used. This is a program to convert raster images to postscript, pdf and other formats.
You can install sam2p in ubuntu by using the following command –
# sudo apt-get install sam2p |
After successful install you can create a shell script file, lets say myfile.sh . Copy the following code and paste it into the myfile.sh .
for file in *.jpg; do echo $file; sam2p $file ${file%.*}.png; done |
The above file which you just created is a shell script file and needs to have proper permission for successful execution. You can simply assign the permission using the following command. Alternatively, you can read more about making shell file using GUI in this post
How to make shell or sh , bin file executable in ubuntu
# sudo chmod +x <strong>myfile.sh</strong> |
Steps to convert JPG files to PNG formation
- Place this file in the same folder where the photos are present and needs to be converted.
- Open the terminal and browse to the folder where the photos are.
- Type the following command and hit Enter.
# sudo ./myfile.sh |
Depending upon the system you are using, all the .jpg files present in that folder will be converted into .png files. You can also convert .jpg to .eps and many other extensions too. For further information visit the google code page for sam2p
Hope this helps.
Stay Digified !!
Digimantra !