How to batch convert JPEG images with jpegtran on Windows
Asked Answered
E

2

6

Is it possible to batch convert a folder of JPEG images using jpegtran on Windows?
I normally use the following command for one file, but I'm not sure how to apply it to an entire directory of JPEG files:

jpegtran -copy none -optimize a.jpg b.jpg

Thank you.

Exhalation answered 12/8, 2015 at 4:31 Comment(2)
Seems that not a programming problem, right? Try asking on SuperUser.Esque
I did just that. Thank you.Exhalation
G
9
  1. Download jpegtran
  2. Put jpegtran.exe in C:/Program Files/Image Optimization (create the folder if it doesn’t exist).
  3. Open your text editor, then copy & paste code below.
  4. Save it as optimize.bat, then put the file in C:/Program Files/Image Optimization.
  5. Run optimize.bat (Run as administrator) to optimize all images in C:/Program Files/Image Optimization (change path in line 3 if you want to optimize another folder).

    @echo off echo Optimizing Images... cd "C:\Program Files\Image Optimization" forfiles /s /m *.jpg /c "cmd /c @\"C:\Program Files\Image Optimization\jpegtran.exe\" -copy none -optimize -outfile @file @file" echo. & echo Process done! pause

The procedure to optimize all images in a folder is described in the following link. I think it might help you.

Optimize All Images in a Folder

Grumpy answered 7/3, 2016 at 5:59 Comment(0)
N
2

I found this a bit simpler which works on one line without needing to make a separate batch file. For example if you want to rotate each file by 90:

forfiles /s /m *.jpg /c "cmd /c jpegtran -rotate 90 @FILE @FILE"

Replace "-rotate 90" with your custom flags for transformation. This script will replace each input file with the transformed output. This assumed jpegtran.exe is in the current directory or system path.

Namesake answered 2/9, 2019 at 17:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.