Is there a simple one liner in Terminal that will:
- Convert all png files in a folder to jpg files preserving base filenames.
- Resize all these files to a specified width while preserving the aspect ratio.
This kind of works but the original filenames are not preserved and I can't tell by the syntax of the command that the aspect ratio is getting preserved:
Convert -resize 1200x900 *.png *.jpg
Ideally I would like something like this to work:
Convert -resize -width 1200 *.png *.jpg
I have read more than ten answers on ask ubuntu but all involve writing loops, scripts, lots of variable syntax, etc. It just feels like there's got to be something simple to at least get the filenames to come out right.
I can live with 1200x900 honoring width and preserving the aspect ratio, but what about when I need the height preserved, which I actually do need sometimes instead.
Thank you!
Update: The marked answer preserves the filenames in a very simple way, which solves my main problem. The first comment leads to how to preserve aspect ratio while specifying width or height desired. All together, I now have the following which solve everything I wanted.
This preserves width:
mogrify -resize 1200x -format jpg *.png
This preserves height:
mogrify -resize x800 -format jpg *.png
The marked answer also added the -quality flag which is really nice:
mogrify -resize 1200x -format jpg -quality 75 *.png
As a bonus, I just love that mogrify overwrites previous output, so I don't end up with a bunch of extra files to delete if I change my mind about size or quality.
Thank you all very much!