Resizing Image Files

T

TT

Hi there,

I've been searching high and low for help on this, but so far, I've struck
out so I thought I would post a quick question here.

I was wondering if anyone could point me in the right direction on how to
resize image files on my computer through vba.

I'm in the process of creating a database to organize my websites photo
albums. I place the pictures I want into a folder on my hard drive, and from
there, the database makes a "thumbnail" subfolder within it and copies the
same images to the subfolder. This is where I'm stuck. I'd then like it to
have the database (vba) resize them to thumbnails (approx 120 x 90 px).

I've used Microsoft's image resizer powertoy which is quite handy, but
ideally, i'd really like the database to handle everything, including the
image resizing.

If someone could help me with the code, or point me in the right direction,
that would be wonderful!

Thanks in advance!!
 
T

TT

Hi Daniel,

Thank you very much for your help. I did some reading on ImageMagick and it
looks like it should be able to do what I need.

I've been trying to get myself familiar with how this works from the command
prompt and then adapting that to VBA. However, it's proven a little more
difficult than expected.

I used this simple command to resize a few images and it worked perfectly
through the command prompt:

P:\> convert "C:\Documents and Settings\xxxxx\Desktop\image.gif" -resize
64x64 "C:\Documents and Settings\xxxxx\Desktop\image_small.gif"

It did exactly what I expected. It copied the image that was there and
resized it to 64x64 pixels.

I've created a routine that looks like this based on a few examples that
I've seen:

Public Sub imagemagick_test()

Dim im As ImageMagickObject.MagickImage
Dim SourceImage, NewImage
Dim msg As Variant

Set im = CreateObject("ImageMagickObject.MagickImage.1")

SourceImage = "C:\Documents and Settings\xxxxx\Desktop\image.gif"
NewImage = "C:\Documents and Settings\xxxxx\Desktop\image_small.JPG"

msg = im.Convert(SourceImage, "-resize", "64x64", NewImage) 'Error Line

End Sub

When I try to execute the command, I get an error that reads, Method
'Convert' of object 'IMagicImage' failed (runtime error'-2147418133
(8000ffff)'.

I've tried all kinds of variations of the path strings, but nothing seems to
be working. If anyone has any insight on this, it would be greatly
appriciated!!

Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top