If I open up a cmd window, cd into the folder containing the convert.exe file and the images and then paste this command everything "just werks" and it spits out the cropped images.
But if I paste the command into a text file, rename it to run.cmd and run it, nothing happens. It just opens up a cmd window and close it again.
How can I get it to work?
Extra points if there is a universal method that works for all cmd commands, i.e. something that opens up a cmd window in the same folder as the bat file is stored (what ever the path name is) and then run the command as if I had pasted it in a cmd window my self. Is something like that even possible?
Okay I found out about the problem I'll show you how: Check the screenshot The faded one is the cmd window of the .cmd file that quickly dissappears the below one is the code pasted into cmd manually. You'll notice there are a few differences, highlighted in yellow font by me The ^ is missing, and so is a lot of the stuff near the end. The reason is that something enclosed in % signs is treated s a variable name by .cmd and .bat files On this page you can read how to escape those characters, it works afterwards as I have tested it. robvanderwoude.com/escapechars.php
No problem, I've had similar problems while trying to automate convert.exe in a project. There's always something with characters that have to be escaped.
John Edwards
in batch files you need to convert % to %%
Christopher Lopez
While you're here, do you know if it's possible to put the imagemagick install directory inside the folder I use for this project and then have convert.exe use that instead of the installed version in C:\Program Files\ImageMagick-7.0.8-Q16?
If not I have to install ImageMagick on every machine I want to run this on, but a fully self referenced portable tool would be much more practical.
Isaiah Ward
yes, just use relative path to the exe
Adrian Rivera
You only need convert.exe in the same folder as the .cmd file
Eli Murphy
If I rename the ImageMagick-7.0.8-Q16? folder in C:\Program Files\ I get a "CORE_RL_MagickCore_.dll is missing error-
Kek, thanks, glad I could help Good luck with your project
Thomas Cooper
this
if you do anything beyond normie GUI programs on windows, you are running the wrong OS and it will be painful as fuck
Luke Gutierrez
>using CLI on windows found the problem, installing linux will fix this.
Cameron Young
Hey! Are you still around?
The command only writes the result to disk after having processed all the images, which cause it to run out of ram on too large conversion jobs. Are there any way to force it to flush the result to disk after x amount of images converted for instance or something along those lines to keep ram and temp space usage low?
Jordan Howard
% signs need to be escaped in batch so instead of %blah do %%blah In command prompt however these are automatically parsed and escaped for you which is why it seems weird
Justin Wood
Personally I use an autohotkey script with the run command to make convert.exe do something I could use the AHK script to index the files and then loop through them all and run the convert.exe on each. That way it would probably be slower, but not run out of ram.
Other than that, sorry, can't help you. You can probably do it in a .bat file though
Wyatt Richardson
CLI filepaths are ALL either relative or absolute. If you did not put the .cmd/.exe/.bat into the same folder as your image or whatever files, you need to use ABSOLUTE filepaths.
Ryan Bennett
What a painful thing to watch, install cygwin or change to Linux I dont know, anything but cmd
Carson Lewis
Hmm, thanks. I've been trying various stuff to get it to work and this:
@ECHO ON
mkdir output
FOR /F "DELIMS=" %%A IN ('DIR /A-D /S /B "jpg2\*.*"') DO Program\convert.exe -limit memory 0 -limit map 0 "%%~A" -geometry 512x512^^ -gravity center -crop 1:1 -quality 100 -set
Seems to do the trick. Both RAM and disk use is minimal and it doesen't increase.
The only problem is that it's soooo slow. I have a million images to scale and I'll be dead by the time this finishes.
Tyler Price
Imagine being a wincuck >tfw I can not only run any fucking script I want, I can map it to a keybind, having it run at x intervals of time, have it run at startup, have it run when I jerk off etc etc.
Ethan Scott
install a real OS chris
Charles Scott
If you think windows can't do all of these you're delusional.
Cameron Jackson
sure, if your time is worth nothing
Adam Carter
A few ideas: convert 100 images at the same time, then start again and take the next 100.
A hacky way to do that would be a for loop (100 times) and copy the files into a temporary folder, then tell imagemagick to convert everything in the temporary folder, then delete the folder and repeat for the next 100 But I'm not a good programmer so that's probably a shit solution
Another idea is to run multiple instances of imagemagick at the same time, so it does multiple in parallel.
Google also states that imagemagick's "mogrify" file is good for millions of images, might want to look into that. Gotta sleep now, good luck
Isaac Gonzalez
When I changed to mogrify things seem much faster but now none of the commands work and it doesen't want to save anything.. Back to the drawing board I guess.
Justin Price
Thanks again, I'll head to bed as well. Gotta try again tomorrow. Sleep well user.
Parker Scott
it can, but will take you 10x more time and nerves
Carson Ramirez
i've made so many neat things with imagemagick. it's a great program to automate social media posting for example.
This was all done using imagemagick. And the posts were really popular, though instagram started to shadow ban my posts and I stopped the project because fuck that.