Copying name from image_A to Output file - naming convention Issue

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
bielsen
Posts: 1
Joined: 2015-07-22T07:34:36-07:00
Authentication code: 1151

Copying name from image_A to Output file - naming convention Issue

Post by bielsen »

Hello ImageMagick Community!

Recently I was looking for a tool that could combine certain attributes from two different images (in my example it was copying alpha channel from image_Alpha to image_Beauty). I've managed to solve this issue with usage of convert tool from IM and the line of code look's like this:

convert.exe image_A_Beauty.png image_A_Alpha.png -alpha Off -compose CopyOpacity -composite image_A_Output.png
convert.exe image_B_Beauty.png image_B_Alpha.png -alpha Off -compose CopyOpacity -composite image_B_Output.png
and so on...

Everything works as it should but I want to automate this process somehow. The goal of my task is to find a solution on how to save output file in a certain location, and the Output file should have the exact same name as file without alpha channel (image_A.png - without the _Beauty extension in the naming).

I'm not fluent at all in batch commands - up till now I was using not too complex commands just to automate some rendering processes in maya and in after effects :) Any help or an example is more than welcome.

I'm using ImageMagick-7.0.0-0-portable-Q16-x64 under Win7Enterprise Sp1

Thank you,
Peter
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Copying name from image_A to Output file - naming convention Issue

Post by fmw42 »

I do not think there is any simple way to do this in IM. You likely will need to learn window batch scripting so you can loop over each image and control the output name and location. However, I am not a Windows users, so do not know how to do this in Windows.

There is a new internal scripting method in IM 7, as noted in http://imagemagick.org/script/porting.php#cli, but I have not seen any examples to detail how that works.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Copying name from image_A to Output file - naming convention Issue

Post by snibgo »

This seems to be a question about scripting in Windows.

I think BAT is probably easiest to learn. There are plenty of resources on the web about writing BAT scripts. Alternatives include Powershell (which may already be installed on your Windows computer) and bash (which is available through Cygwin).
snibgo's IM pages: im.snibgo.com
Post Reply