More input files from variable

ImageMagickObject is a Windows COM+ interface to ImageMagick. COM+, Visual Basic, and Delphi users should post to this discussion group.
Post Reply
Jova
Posts: 1
Joined: 2015-04-02T21:55:37-07:00
Authentication code: 6789

More input files from variable

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: More input files from variable

Post 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.
snibgo's IM pages: im.snibgo.com
Alexvb6
Posts: 49
Joined: 2012-10-12T16:50:15-07:00
Authentication code: 67789

Re: More input files from variable

Post 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
Post Reply