Page 1 of 1

More input files from variable

Posted: 2015-04-02T22:39:35-07:00
by Jova
Hello,

I have problem with syntax of method Convert in WHScript.


First part of this script will create more jpg files (about 300) with names according scheme RowIndex & "_" & ColumnIndex & "jpg" (example: 10_2.jpg, 16_12.jpg).

Names of created files are save in variable strInputFiles as string. After every done all files for Row, It should create horizont panorama.


When I write down names input files manualy, it's all right:

Code: Select all

dim objIMG

set objIMG = CreateObject("ImageMagickObject.MagickImage.1")

objIMG.create ("10_1.jpg","10_2.jpg","10_3.jpg","10_....","+append","outputFile.jpg")
But when I use variable strInputFiles, is this use only as one input file with name from strInputFiles.

Code: Select all

dim strInputFiles

strInputFiles = " ""10_1.jpg"",""10_2.jpg"",""10_3.jpg"",""10_...."" "

objIMG.create (strInputFiles,"+append", "outputFile.jpg")
I can't use *.jpg because files will be sort 1,10,11,1...,2,. It's for panorama impossible.

Re: More input files from variable

Posted: 2015-04-02T23:43:05-07:00
by snibgo
I don't know, but you might use the technique shown in viewtopic.php?f=8&t=13198

When the order of images is important, it is better to use leading zeros in filenames, eg "01", "02" etc.

Re: More input files from variable

Posted: 2018-03-29T20:14:39-07:00
by Alexvb6
Hi Jova,

You would have to declare a huge (300+) VB Array first, then fill it with your filenames.
Also, the method to use is "o_objIMG.Convert", not "o_objIMG.Create".

Code: Select all

Option Explicit

'Declare variables
'-----------------
'IM Object
dim o_objIMG

'String containing all your filenames
dim s_filesList

'Array containing all the parameters that will be sent to IM
'Here, I initialize the array with 300 slots. Each slot have the VB TypeName "Empty" by default.
dim a_filesArray
redim a_filesArray(300)


'Fill your files list
s_filesList = "10_1.jpg,10_2.jpg,10_3.jpg" 'And so on...


'Create a temporary array of all your files
a_tmp = Split(s_filesList, ",")


'Loop through each item of the temporary array, then put it into the Array ("a_filesArray") containing all the parameters that will be used by IM.
for i_file = 0 to Ubound(a_tmp)
	a_filesArray(i_file) = a_tmp(i_file)
next

'In COM+, IM cannot receive a VB Array directly; it needs to receive EACH ITEM OF THE ARRAY, so this lead to a very long command-line.
'In this example, only the first 3 items of "a_filesArray" are filled. The 297 others have VB TypeName "Empty".
'When IM encounters an "Empty" parameter, it simply ignores it and continue. This way, the following lines will work with either 3 files or 300.
'Please note that the parameter have to be Empty, and not "". Such a blank string "" IS a parameter for IM, and would crash it.
set o_objIMG = CreateObject("ImageMagickObject.MagickImage.1")

	o_objIMG.Convert(a_filesArray(0), a_filesArray(1), a_filesArray(2), a_filesArray(3), a_filesArray(4), a_filesArray(5), [...AND SO ON...], "+append", "c:\outputFile.jpg")

	'In this case, as only 3 items were defined in the array, this would equal to :
	o_objIMG.Convert("10_1.jpg", "10_2.jpg", "10_3.jpg", Empty, Empty, Empty, [...AND SO ON...], "+append", "c:\outputFile.jpg")

set o_objIMG = Nothing