richard
richard

Reputation: 1536

Batch resize images and output images to new folder with ImageMagick

Current image folder path:

public_html/images/thumbs

Output image folder path:

public_html/images/new-thumbs

I have 10 video thumbs per video in current folder, named of image thumbs:

1-1.jpg
1-2.jpg
1-3.jpg
1-4.jpg
1-5.jpg (Resize)
1-6.jpg
1-7.jpg
1-8.jpg
1-9.jpg
1-10.jpg

2-1.jpg
2-2.jpg
2-3.jpg
2-4.jpg
2-5.jpg (Resize)
2-6.jpg
2-7.jpg
2-8.jpg
2-9.jpg
2-10.jpg

I want to resize all 5th images(*-5.jpg) to the new folder. I've tried below command but no luck:

mogrify 
-path 
  public_html/images/thumbs/*-5.jpg 
-resize 16×12 
-quality 100 
  public_html/images/new-thumbs/*-5.jpg

Upvotes: 109

Views: 127353

Answers (4)

Viranga
Viranga

Reputation: 49

In my case, I used version 7.1.1.

F:\Dataset\images>c:\"Program Files"\ImageMagick\mogrify -quality 50 -path ..\lowquality\ *

This code should be executed from the original image folder and directed to a new folder location to save.

And do not forget to add "" to "Program Files" or else it will return this error

c:\Program: The term 'c:\Program' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Upvotes: 0

Dmytro Vyprichenko
Dmytro Vyprichenko

Reputation: 4924

"Mogrify" should be called from the directory with the original thumbnails, while the -path parameter is for pointing target directory.

mkdir public_html/images/new-thumbs
cd public_html/images/thumbs
magick mogrify -resize 16x12 -quality 100 -path ../new-thumbs *.jpg

http://www.imagemagick.org/Usage/basics/#mogrify

The last arguments are the list of files, so you can filter by name 1-*.jpg for example.

Upvotes: 153

Nigidoz
Nigidoz

Reputation: 478

Suggested solutions do not work properly on the latest ImageMagick (at least, on macOS). Command, that works overwriting source images is as follows:

magick mogrify -path ./ -resize 50% -quality 80 *.jpg

To avoid overwriting the original images, write to a new folder:

magick mogrify -path path/to/destination/folder/ -resize 50% -quality 80 *.jpg

Upvotes: 27

Bricktop
Bricktop

Reputation: 67

For those having Shotwell installed on Ubuntu/Debian, following may be more easy to export selected images in a folder to another folder through processing the images as needed.

  • Open Shotwell
  • Select the images you want to export
  • File > Export
  • Adjust the values to your needs
  • Select the folder to export

Upvotes: 2

Related Questions