Newb: IM and Excel VBA
-
- Posts: 6
- Joined: 2011-08-18T12:16:18-07:00
- Authentication code: 8675308
Newb: IM and Excel VBA
First off, I am a complete and utter newb to ImageMagick. Thus, the chance that this is a stupid question is pretty high. I have searched this forum and the web for VBA and ImageMagick, but haven't found anything directly helpful yet.
I am trying to use an Excel VBA macro to create an image from scratch, not modify an existing image. I plan on looping through the entire image, setting each pixel's color depending on it's value in several equations within Excel.
I am running 64-bit Windows 7 Home and Excel 2007. The ImageMagickObject 1.0 Type Library dll is registered. The version of ImageMagick I downloaded is ImageMagick-6.7.1-7-Q16-windows-x64-dll.
Dim objMap As New MagickImage
t = objMap.Convert("C:\Mapping\Maps\Auto\base.png", "-size", xlim & "x" & ylim, "C:\Mapping\Maps\Auto\test.png")
I receive the error message: 'Run-time error '429': ActiveX component can't create object'
Any help in getting started would be great.
Thanks,
TMO
I am trying to use an Excel VBA macro to create an image from scratch, not modify an existing image. I plan on looping through the entire image, setting each pixel's color depending on it's value in several equations within Excel.
I am running 64-bit Windows 7 Home and Excel 2007. The ImageMagickObject 1.0 Type Library dll is registered. The version of ImageMagick I downloaded is ImageMagick-6.7.1-7-Q16-windows-x64-dll.
Dim objMap As New MagickImage
t = objMap.Convert("C:\Mapping\Maps\Auto\base.png", "-size", xlim & "x" & ylim, "C:\Mapping\Maps\Auto\test.png")
I receive the error message: 'Run-time error '429': ActiveX component can't create object'
Any help in getting started would be great.
Thanks,
TMO
-
- Posts: 6
- Joined: 2011-08-18T12:16:18-07:00
- Authentication code: 8675308
Re: Newb: IM and Excel VBA
I have checked, and I have the most recent DirectX. The ImageMagick Display program opens when I run it from the Start Menu, although I have not tried to use it through the command line yet.
-
- Posts: 6
- Joined: 2011-08-18T12:16:18-07:00
- Authentication code: 8675308
Re: Newb: IM and Excel VBA
I ran the size command from the dos command line, and it processed with no errors, although it did not resize the image, it did create the output png file. I will dig a bit further into why it didn't resize, if it's user error or program.
-
- Posts: 6
- Joined: 2011-08-18T12:16:18-07:00
- Authentication code: 8675308
Re: Newb: IM and Excel VBA
Ran this command from instructions that came with ImageMagick:
convert -size 320x85 canvas:none -font Bookman-DemiItalic -pointsize 72 \
-draw "text 25,60 'Magick'" -channel RGBA -blur 0x6 -fill darkred -stroke magenta \
-draw "text 20,55 'Magick'" fuzzy-magick.png
Only thing I changed was the font to one I have installed. It created a 320x85 black rectangle as the output. No text. It's sounding to me like it's not installed quite right, although it could still be just about anything. Anybody have any ideas, or am I on my own with this one?
convert -size 320x85 canvas:none -font Bookman-DemiItalic -pointsize 72 \
-draw "text 25,60 'Magick'" -channel RGBA -blur 0x6 -fill darkred -stroke magenta \
-draw "text 20,55 'Magick'" fuzzy-magick.png
Only thing I changed was the font to one I have installed. It created a 320x85 black rectangle as the output. No text. It's sounding to me like it's not installed quite right, although it could still be just about anything. Anybody have any ideas, or am I on my own with this one?
- whugemann
- Posts: 289
- Joined: 2011-03-28T07:11:31-07:00
- Authentication code: 8675308
- Location: Münster, Germany 52°N,7.6°E
Re: Newb: IM and Excel VBA
I would like to try to access the COM+ object from Excel VBA, too, but I cannot figure out how to install the COM+ object.
http://www.imagemagick.org/www/ImageMagickObject.html claims it to be part of the Window installation, but I can't see that. When installing the binary releases (either dynamically linked or statically linked), I have never seen the checkbox "Register ImageMagickObject", as this page claims. The path " c:\Program Files\ImageMagick\ImageMagickObject" doesn't exist on my computer.
What is the trick?
http://www.imagemagick.org/www/ImageMagickObject.html claims it to be part of the Window installation, but I can't see that. When installing the binary releases (either dynamically linked or statically linked), I have never seen the checkbox "Register ImageMagickObject", as this page claims. The path " c:\Program Files\ImageMagick\ImageMagickObject" doesn't exist on my computer.
What is the trick?
Wolfgang Hugemann
- whugemann
- Posts: 289
- Joined: 2011-03-28T07:11:31-07:00
- Authentication code: 8675308
- Location: Münster, Germany 52°N,7.6°E
Re: Newb: IM and Excel VBA
I just thought of different solution for your problem:
You could simply avoid using the ImageMagick Object and write a simple text file, say Test.txt, in ImageMagick's TXT format:
This can later be converted to whatever format you like by
You could simply avoid using the ImageMagick Object and write a simple text file, say Test.txt, in ImageMagick's TXT format:
Code: Select all
# ImageMagick pixel enumeration: 3,3,65535,rgb
0,0: (65535,65535,65535)
1,0: (65535,65535,65535)
2,0: (65535,65535,65535)
0,1: (32768,32768,32768)
1,1: (32768,32768,32768)
2,1: (32768,32768,32768)
0,2: ( 0, 0, 0)
1,2: ( 0, 0, 0)
2,2: ( 0, 0, 0)
Code: Select all
convert test.txt test.gif
Wolfgang Hugemann
-
- Posts: 6
- Joined: 2011-08-18T12:16:18-07:00
- Authentication code: 8675308
Re: Newb: IM and Excel VBA
Crap, you're right. I hadn't made it that far yet. I have an ImageMagickObject folder, but all it has in it is a README and a Tests folder with some test cases. So unless someone comes up with an answer, it's useless to keep trying this method.whugemann wrote:I would like to try to access the COM+ object from Excel VBA, too, but I cannot figure out how to install the COM+ object.
http://www.imagemagick.org/www/ImageMagickObject.html claims it to be part of the Window installation, but I can't see that. When installing the binary releases (either dynamically linked or statically linked), I have never seen the checkbox "Register ImageMagickObject", as this page claims. The path " c:\Program Files\ImageMagick\ImageMagickObject" doesn't exist on my computer.
What is the trick?
The batch method had actually been my original plan before I found out I supposedly could connect directly to IM, but I hadn't found out how to do it yet. I will give that a try next.
I copied your test code, and it worked fine, so I'll just change my VBA code to produce a text file instead.
-
- Posts: 6
- Joined: 2011-08-18T12:16:18-07:00
- Authentication code: 8675308
Re: Newb: IM and Excel VBA
Looks like this method is working! It is producing images as desired, although my algorithms still need a lot of work. Thanks for your help!
- whugemann
- Posts: 289
- Joined: 2011-03-28T07:11:31-07:00
- Authentication code: 8675308
- Location: Münster, Germany 52°N,7.6°E
Re: IM and Excel VBA
Now that I know how to install the COM+ object (viewtopic.php?f=8&t=19332), I have just successfully envoked the COM+ object from Excel VBA:
This minimal test program just creates the IM logo and stores it as a test.gif in the same folder as the workbook in which the code is embedded. This functioned with Excel 97 under Windows XP SP3.
I do, however, not see how using the COM+ object can help you with your original problem. Could you explain your project a little bit? I would like to incorporate something alike in http://www.imagemagick.org/Usage/windows -- working title "Creating Images from the Scratch".
Code: Select all
Sub Testit()
Set img = CreateObject("ImageMagickObject.MagickImage.1")
img.Convert "logo:", ThisWorkbook.Path & "\test.gif"
Set img = Nothing
End Sub
I do, however, not see how using the COM+ object can help you with your original problem. Could you explain your project a little bit? I would like to incorporate something alike in http://www.imagemagick.org/Usage/windows -- working title "Creating Images from the Scratch".
Wolfgang Hugemann