Convert Windows batch script to C#

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
ElPeta
Posts: 8
Joined: 2019-08-30T16:48:48-07:00
Authentication code: 1152

Convert Windows batch script to C#

Post by ElPeta »

Hi all,

I have a windows batch script that adds a watermark to every jpg file it finds on a given folder, and sequentially renames it to "IMGxxx.jpg". It works perfectly, but I want to put it in a Windows form in C#. I have already referenced Magick.NET in my C# solution, but syntax is way different than I had figured out for batch coding.

My script looks like this:

Code: Select all

for /L %%i in (1,1,%cnt%) do ^
composite -dissolve 70% ^
-geometry +80+80 ^
-gravity southwest ^
Logo/MyLogoName.png ^
Input/IMG%%i.jpg Output/IMGwm%%i.jpg
Could someone please help? I'm clueless!

Thanks in advance.

snibgo
Posts: 12894
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert Windows batch script to C#

Post by snibgo »

Where is the difficulty? Your program could simply have a loop, and build the "composite" command and call it within the loop.
snibgo's IM pages: im.snibgo.com

ElPeta
Posts: 8
Joined: 2019-08-30T16:48:48-07:00
Authentication code: 1152

Re: Convert Windows batch script to C#

Post by ElPeta »

Thanks Snibgo. The difficulty is that I don't know how to do this. How do I build the "composite" command within a loop, and then call it?

snibgo
Posts: 12894
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert Windows batch script to C#

Post by snibgo »

I suggest you read C# documentation, for example at https://docs.microsoft.com/en-us/dotnet/csharp/
snibgo's IM pages: im.snibgo.com

Post Reply