Com+ syntax for resizing images?

ImageMagickObject is a Windows COM+ interface to ImageMagick. COM+, Visual Basic, and Delphi users should post to this discussion group.
Post Reply
aljbookworm

Com+ syntax for resizing images?

Post by aljbookworm » 2010-11-12T08:02:23-07:00

How do you get the com object to do anything other than just convert file formats?
I can get that to run just fine but if I try to resize an image it does nothing, no errors, it just creates the new file but with out resizing it.

Code: Select all

$com_IM = new COM('ImageMagickObject.MagickImage.1');
$img = $com_IM->Convert($Logo,'-resize','80x60',$newImage);
$Logo is the original image and $newImage is the name of the new one.
Yes this is written in php but it says that you are supposed to be able to use it with the imagemagickobject and it works fine converting file formats.
Any ideas about what the correct syntax would be or why it would not also resize the image?

spieler
Posts: 47
Joined: 2004-10-08T09:03:16-07:00
Location: Iowa

Re: Com+ syntax for resizing images?

Post by spieler » 2010-11-15T13:11:28-07:00

Your code looks fine -- each argument needs to be it's own parameter like you have done it.

Please try this from the command line. The magickcmd command is a wrapper around the Com+ object.

Code: Select all

identify logo:
magickcmd convert logo: -resize 80x60 temp.png
identify temp.png
On my system I get

Code: Select all

logo:=>LOGO LOGO 640x480 640x480+0+0 8-bit PseudoClass 256c 37.4kb
temp.png PNG 80x60 80x60+0+0 8-bit DirectClass 4.36kb
so that means the object can resize just fine.

I'm not familiar with PHP, so I'm not going to be able to troubleshoot much. What happens when you pass in the additional parameters in as variables like the original and new file names? I wouldn't think that would make a difference, though....

Gary

aljbookworm

Re: Com+ syntax for resizing images?

Post by aljbookworm » 2010-11-15T14:27:32-07:00

Actually my real problem is that the code works but only some of the time, and I cannot figure out what triggers it to work and what triggers it to not work. It does not seem to be file format or image size, just that one time it will, and the next time it will not, or I wait an hour or so and try one that did not work before and it seems to work resizing it just fine.
I cannot pass in the first file name in as a string but for some reason it only takes a variable. That is fine with me since the application that I need it for requires that anyway. It never seemed to work right when I passed in the additional parameters as variables.

spieler
Posts: 47
Joined: 2004-10-08T09:03:16-07:00
Location: Iowa

Re: Com+ syntax for resizing images?

Post by spieler » 2010-11-15T14:37:20-07:00

Are you cleaning up your object properly? If not, that might be causing some memory problems?

Another option, although probably not preferred is to call out tom the command line instead of using the object. The command line is solid, although the object has worked pretty reliably for me for a while now.

aljbookworm

Re: Com+ syntax for resizing images?

Post by aljbookworm » 2010-11-15T14:41:08-07:00

unfortunately going just from the command line is not an option since this is for a site and to run the exec on the command line requires too much of a loosening on permissions. I will double check to make sure that I am closing everything off correctly on the object.

Post Reply