Need to Batch .JPG Modify - Linux

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

I'm pretty sure the problem lies with the quotes that you use in the for statement. You've used the normal quote character whereas I think you need back-quotes:
for image in `ls *.jpg`

Best Wishes
Pete
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

A number of methods, are listed at the end of a description of the mogrify command in IM examples. I just added the above advanced xargs simpification, to that section

mogrify examples...
http://www.cit.gu.edu.au/~anthony/graph ... ogrify_not
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Post by glennrp »

Use

Code: Select all

for image in *.jpg
not

Code: Select all

for image in ls *.jpg
which expands to

Code: Select all

ls
file0.jpg
...
fileN.jpg
and then cannot find the file called "ls".
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

To remove the instances of things like thumbnail.jpg use

Code: Select all

for image in *.jpg
in
  case "$image" in
  *.thumbnail.jpg) continue ;;
  esac
  ...
done
The case will have the script ignore the file names that matched.

For a recursive 'find' method use

Code: Select all

find . -type f -name '*.jpg' \! -name '*.thumbnail.jpg' | xargs ....
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply