Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert jpg files into png files with linux command? + Difficulty = Subfolders

Tags:

I want to convert several jpg files into png files. As far as I know, one can use this command

mogrify -format png *.* 

I have one problem, I have a lot of subfolders. Let's say a is my main folder and b,c and d are subfolders. The images are in the subfolders.

How can I convert all images without having to open every folder manually?

-> I would like to write a command that works, when I am in folder a, but works for all files in the subfolders.

like image 936
Merrythought Avatar asked Jan 07 '14 15:01

Merrythought


People also ask

How do I convert multiple jpegs to PNG?

Open Finder and select the images you want to convert. Open them in Preview and then Select All. Go to "File" and choose "Export Selected Images". Choose the export format as PNG.

How do I convert a JPG File to a PNG file?

In Windows, open JPG in Microsoft Paint, and click File > Save as > PNG > Save. In Photoshop (Windows or Mac), go to File > Save as > Save as type > PNG > Save. Or File > Export > Export As > PNG > Export. In Preview on Mac, select File > Export > Export As > Format > PNG > Save.

How do I save a PNG file in Linux?

First, you need to open an image in GIMP by clicking on the File then Open. Now, complete the editing and go to the “Export as” option under the File section, or use the “Shift,CTRL and E” as shortcut keys. After that, select the file type to convert the image into your desired format, which is PNG in this topic.

Can I just rename PNG to JPG?

png file, you can just rename image. png to image. jpeg or image. gif , and it automatically gets converted to the other format and works perfectly fine.


Video Answer


1 Answers

Assuming you're in folder a the following might work for you

find . -name "*.jpg" -exec mogrify -format png {} \; 

You can use the find command to get all the jpg files in all the subfolders and pass your command as an argument to find

like image 199
arco444 Avatar answered Nov 15 '22 19:11

arco444