What command i need to run to put in img/ folder with same name on ubuntu jpg file with 35% quality converter from jp2? On windows i run such bat:

for /d %%d in (*) do (
  for %%f in ("%%~d\*.jp2") do (
    convert -limit memory 0 -limit map 0 "%%~ff" -quality 20 "%%~dpf\jpg\%%~nf.jpg"

but what and how to do with ubuntu to convert jp2 to jpg with 35% and put jpg's in /img folder?


I can't speak for the quality setting because I haven't looked it up but when I want to process a lot of images I normally run them into another location using mogrify. I just converted a whole directory of TIF images on Ubuntu using the following.

mogrify -path tmp -format jpg -quality 35 *.tif

All the images retained their name, were converted into JPG, and were placed into a subdirectory called tmp. I could have specified a full path, but this is how I normally do it so it was already set up.

Mogrify will write over images in place (if you don't specify the path) so test the command and be careful until comfortable with it.

  • note! from jp2 to jpg – brabertaser19 Feb 24 '13 at 13:40
  • Good point, though I was just showing an example, had a folder of TIFs and wanted to copy and paste the exact command line. So it should be noted that there are several options and permutations possible. This is just an example of how to use mogrify on several images into another folder. – Dennis Feb 24 '13 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.