Page 1 of 1

Imagemagick help (well really a DOS scripting question)

Posted: 2019-05-03T22:36:04-07:00
by Jaredma
Hey there.

So trying to keep two up to date versions of tiles at 50px and 100px is a pain. Clearly the better plan is to keep the 100px one up to date and then copy and resize this directory whenever I update. I must be able to do this using basic DOS scripts and imagemagick, but I can't figure it out for the life of me.

The imagemagick command is actually pretty straightforward:
mogrify -resize 50% *.png

The one problem I have with this is that it results the correct sized image in pixels, but no real gain in filesize. Any thoughts?

However the real trouble here is the DOS scripting required to run this on a folder and and all of its subdirectories. Any ideas? Any help much appreciated - and rewarded with a healthy dose of rep

Re: Imagemagick help (well really a DOS scripting question)

Posted: 2019-05-03T23:17:05-07:00
by fmw42
I have moved this post, since the Consulting forum is for PAID consulting only.

I suggest you Google about Windows batch scripting as this forum is not really about scripting but about Imagemagick processing. However, you may get lucky and one of the Windows users may provide help. Sorry, I am not a PC/Window/DOS user, so cannot help you.

I suggest you make a list of directories and use a for loop over each directory and use mogrify to process each directory. Imagemagick mogrify will not traverse subdirectories.

See for example https://ss64.com/nt/for.html and https://www.computerhope.com/forhlp.htm There are plenty of resources out there on the web.

Depending upon your input type and color depth, file size might increase or not decrease by much when using -resize, since it creates new pixels from the resampling.

You have not informed us about the color depth of your input images?

Re: Imagemagick help (well really a DOS scripting question)

Posted: 2019-05-04T02:13:56-07:00
by snibgo
Windows BAT syntax:

Code: Select all

for /R %%F in (.) do (
  pushd %%~pF
  mogrify -resize 50%% *.png
  popd
)
For help on "for", type "help for" at the command prompt.