Page 1 of 2

Please help with the batch file

Posted: 2018-11-12T07:58:41-07:00
by line7
We are fast migrating from Xnconvert.

Can you please help us formulate a batch file which will do these two simple actions:

crop image by 10 pixels from all sides
sharpen image by 20%

overwrite all png files in folder:

C:\test

Thanks a lot!!!

PS: I understand this script can be run in a batch command file (bat)?

Re: Please help with the batch file

Posted: 2018-11-12T08:08:43-07:00
by snibgo
What version of IM? Have you read any of the documentation?

What does "sharpen image by 20%" mean?

Re: Please help with the batch file

Posted: 2018-11-12T08:15:17-07:00
by line7
yes I am currently reading the manual - was thinking this was a rather simple operation but being a noin programmer will take some time to formulate properly.....we installed ImageMagick-7.0.8-14-Q16-x64

Re: Please help with the batch file

Posted: 2018-11-12T08:27:45-07:00
by snibgo
Yes, it is simple, for example:

Code: Select all

magick mogrify -shave 10x10 -sharpen 2 *.png
But I don't know what you mean by "sharpen image by 20%".

Re: Please help with the batch file

Posted: 2018-11-12T08:31:22-07:00
by line7
well - there must be a grading of the sharpening? or like sharpen one step?

Re: Please help with the batch file

Posted: 2018-11-12T08:50:01-07:00
by line7
can it just sharpen the images once?

Re: Please help with the batch file

Posted: 2018-11-12T08:51:11-07:00
by line7
fantastic1
what does this mean? can you please help?

-sharpen 2

Re: Please help with the batch file

Posted: 2018-11-12T08:56:38-07:00
by line7
please forgive me for this super dumb question but how do I set the directory for the imagemagick to operate via a BAT file? Can you please show me an example of the full script file in a bat?

Re: Please help with the batch file

Posted: 2018-11-12T13:20:50-07:00
by line7
another super dumb question - can I run the whole script inside a BAT file which will contain all instructions? can someone please show me an example of such file if this is possible?

Re: Please help with the batch file

Posted: 2018-11-12T13:36:12-07:00
by fmw42
Sorry, I am not a Windows user. But about sharpening. -sharpen RadiusxSigma or -sharpen 0x2 for example with sharpen with a Gaussian function whose sigma=2 (standard deviation). The larger the sigma the more sharpening. The radius=0 means for the function to find the optimum radius or window size for the Gaussian function. So I usually leave it at 0. See https://imagemagick.org/script/command- ... hp#sharpen

Another sharpening tool is -unsharp, which is similar to -sharpen, but has more tuning arguments. see https://imagemagick.org/script/command- ... hp#unsharp

For examples, see https://imagemagick.org/Usage/blur/

Re: Please help with the batch file

Posted: 2018-11-12T14:03:18-07:00
by snibgo
line7 wrote:well - there must be a grading of the sharpening? or like sharpen one step?
I suggest you experiment with "-sharpen" or "-unsharp" to find the parameters that give you what you want. If you provide before and after images of "sharpen image by 20%", perhaps we can suggest the settings.

The command I showed can be put in a BAT file. And that's it, a complete script. It will change all the PNG files in the current directory.

To change to a directory, use the Windows "cd" command first.

Re: Please help with the batch file

Posted: 2018-11-13T02:01:20-07:00
by line7
glads to see you here! I made a quantum leap today and was able to create this batch script file which should supposedly work fine but id does not work(((( can someone please take a look?

Code: Select all

cd "C:\test"

mogrify -shave 10x10-sharpen 2 *.*


pause
it seems to run code fine but then nothing is performed on the pictures...they remain the same...

Re: Please help with the batch file

Posted: 2018-11-13T02:05:36-07:00
by line7
I changed the code to make the changes more prominent and still it does not operate on the pictures - please help!)

Code: Select all

cd "C:\test"

magick mogrify -colorspace gray -shave 10x10 -sharpen 2 *.jpg


pause

Re: Please help with the batch file

Posted: 2018-11-13T02:09:06-07:00
by line7
my antivirus (Comodo) was blocking the bat file - now it seems to work great!)))))!)!)!)!))!)!)!)

Re: Please help with the batch file

Posted: 2018-11-13T02:29:13-07:00
by line7
I noticed my CPU is taking like 30% of its power (this is a 16 core xeon E5-2680) to modify 28 images in like 40 seconds (thought this was easy:) - I wonder if shave is resource intensive? can this be done by simple cropping? images are all 1 mb size and 2300X1900 PIXELS WIDE