Image Resize

Image Resize

am 15.01.2008 08:56:16 von Dominic Vella

Hi, I know I seem to have the really complicated questions, but I guess
that's why I'm here. This is a little verbose, only because I've been
trying to crack this for a week now.

Your help would be appreciated.

I've been trying numerous ways to resize images, as I want to make store
thumbnails, not full images in my database.

------------------------------------------------------------ -----------------
Method 1: So I tried the VB way -
that is to use LoadPicture to a picture box, resize the box, then copy to
another box and then 'SavePicture Picture2.Picture,strFilename'

That doesn't work as the controls in Access are somewhat different. So I
tried

------------------------------------------------------------ ----------------
Method 2: Access Image and OLEBoxes. -
image1.picture = strFilename

That doesn't work because the picture property is only a filename, I've
tried 'SavePicture image1.PictureData', but it won't work.

------------------------------------------------------------ -------------------
Method 3: The IPicture Object
Dim imgPicture as Object
Set imgPicture = LoadPicture(filename)

But then I can't resize the image. Once upon a time I think LoadPicture
allowed you to use incoming dimensions stdole.StdFunctions.LoadPicture, but
when I did the SavePicture, the dimensions never changed, and in fact the
file size grew bigger due to loss of compression.

------------------------------------------------------------ ------------------
All Up: this is what I have so far:
Sub ResizeImageWithAspect(strFilename As String, strOutputFilename As
String, intNewWidth As Integer, intNewHeight As Integer)
On Error GoTo Err_Sub
Dim imgOriginal As Object
Dim ctl As Control ' I can't get image data back if I save image to
control
Dim sglAspect As Single
Dim intTempHeight As Integer

Set imgOriginal = LoadPicture(strFilename)
sglAspect = imgOriginal.Height / imgOriginal.Width
intTempHeight = intNewWidth * sglAspect

If intTempHeight > intNewHeight Then
sglAspect = imgOriginal.Width / imgOriginal.Height
intNewWidth = intNewHeight * sglAspect
Else
intNewHeight = intTempHeight
End If
Set imgOriginal = LoadPicture(strFilename)

''''''''''''''
'Image Resize needed here
''''''''''''''''

SavePicture imgOriginal, strOutputFilename
Exit_Sub:
DoCmd.Close acForm, "frmWebPictureResize"
Set imgOriginal = Nothing
Exit Sub
Err_Sub:
MsgBox Err.Number & ": " & Err.Description
' Resume Exit_Sub
Resume Next
End Sub

------------------------------------------------------------ -----------------------
Can anyone tell me how to resize an image in MS-Access? Thanks in advance.

Re: Image Resize

am 15.01.2008 09:40:53 von Arno R

"Dominic Vella" schreef in bericht =
news:478c671a$0$13919$afc38c87@news.optusnet.com.au...
>=20


> Can anyone tell me how to resize an image in MS-Access? Thanks in =
advance.


Hi Diminic,

I think you need ImageMagick to do to this.
http://www.imagemagick.org/script/index.php
It can also do LOTS of other stuff related to images.

Download and check the documentation.
If you need more info on this post back.

Arno R

Re: Image Resize

am 15.01.2008 12:55:54 von Dominic Vella

No, I was hoping the database would be self-contained without having to use
any references unless called by the Declare function or the CreateObject
method.

Maybe there is a way to create a Paintbrush Object, resize and save that
somehow? I still can't find the way. I'd use BltBit (or somethin like
that) stuff on the images, but I can't find any hwnd handles on any of the
MS-Access controls (not that hwnd handles are ever used by Visual Basic
Programmers).

Thanks for the reply anyway.


Dominic


"Arno R" wrote in message
news:478c71a1$0$25477$ba620dc5@text.nova.planet.nl...

"Dominic Vella" schreef in bericht
news:478c671a$0$13919$afc38c87@news.optusnet.com.au...
>


> Can anyone tell me how to resize an image in MS-Access? Thanks in
> advance.


Hi Diminic,

I think you need ImageMagick to do to this.
http://www.imagemagick.org/script/index.php
It can also do LOTS of other stuff related to images.

Download and check the documentation.
If you need more info on this post back.

Arno R

Re: Image Resize

am 15.01.2008 14:55:20 von Stephen Lebans

Dominic I am just heading out the door but I can get you pointed in the
right direction. There is a vbPictureBox class on my site. It is written in
native VBA and contains a resize method.
http://www.lebans.com/imageclass.htm
ImageClass has been replaced by the PictureBoxA97 project. A standard Image
control is wrapped within a class to allow the control to resemble the
standard Visual Basic PictureBox control. Simple drawing methods are
directly supported as is Text output with rotation. A handle to a Device
Context is exposed to allow the developer to use the full range of Graphic
API's. Also supports Screen Grabs, Copy to Clipboard and Save Image control
to a disk Bitmap file. Here is the Access 2000 version, PictureBoxA2K.zip
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Dominic Vella" wrote in message
news:478c671a$0$13919$afc38c87@news.optusnet.com.au...
> Hi, I know I seem to have the really complicated questions, but I guess
> that's why I'm here. This is a little verbose, only because I've been
> trying to crack this for a week now.
>
> Your help would be appreciated.
>
> I've been trying numerous ways to resize images, as I want to make store
> thumbnails, not full images in my database.
>
> ------------------------------------------------------------ -----------------
> Method 1: So I tried the VB way -
> that is to use LoadPicture to a picture box, resize the box, then copy to
> another box and then 'SavePicture Picture2.Picture,strFilename'
>
> That doesn't work as the controls in Access are somewhat different. So I
> tried
>
> ------------------------------------------------------------ ----------------
> Method 2: Access Image and OLEBoxes. -
> image1.picture = strFilename
>
> That doesn't work because the picture property is only a filename, I've
> tried 'SavePicture image1.PictureData', but it won't work.
>
> ------------------------------------------------------------ -------------------
> Method 3: The IPicture Object
> Dim imgPicture as Object
> Set imgPicture = LoadPicture(filename)
>
> But then I can't resize the image. Once upon a time I think LoadPicture
> allowed you to use incoming dimensions stdole.StdFunctions.LoadPicture,
> but when I did the SavePicture, the dimensions never changed, and in fact
> the file size grew bigger due to loss of compression.
>
> ------------------------------------------------------------ ------------------
> All Up: this is what I have so far:
> Sub ResizeImageWithAspect(strFilename As String, strOutputFilename As
> String, intNewWidth As Integer, intNewHeight As Integer)
> On Error GoTo Err_Sub
> Dim imgOriginal As Object
> Dim ctl As Control ' I can't get image data back if I save image to
> control
> Dim sglAspect As Single
> Dim intTempHeight As Integer
>
> Set imgOriginal = LoadPicture(strFilename)
> sglAspect = imgOriginal.Height / imgOriginal.Width
> intTempHeight = intNewWidth * sglAspect
>
> If intTempHeight > intNewHeight Then
> sglAspect = imgOriginal.Width / imgOriginal.Height
> intNewWidth = intNewHeight * sglAspect
> Else
> intNewHeight = intTempHeight
> End If
> Set imgOriginal = LoadPicture(strFilename)
>
> ''''''''''''''
> 'Image Resize needed here
> ''''''''''''''''
>
> SavePicture imgOriginal, strOutputFilename
> Exit_Sub:
> DoCmd.Close acForm, "frmWebPictureResize"
> Set imgOriginal = Nothing
> Exit Sub
> Err_Sub:
> MsgBox Err.Number & ": " & Err.Description
> ' Resume Exit_Sub
> Resume Next
> End Sub
>
> ------------------------------------------------------------ -----------------------
> Can anyone tell me how to resize an image in MS-Access? Thanks in
> advance.
>
>
>

Re: Image Resize

am 15.01.2008 16:29:50 von Arno R

"Dominic Vella" schreef in bericht =
news:478c9f41$0$13959$afc38c87@news.optusnet.com.au...
> No, I was hoping the database would be self-contained without having =
to use=20
> any references unless called by the Declare function or the =
CreateObject=20
> method.
>=20
> Maybe there is a way to create a Paintbrush Object, resize and save =
that=20
> somehow? I still can't find the way. I'd use BltBit (or somethin =
like=20
> that) stuff on the images, but I can't find any hwnd handles on any of =
the=20
> MS-Access controls (not that hwnd handles are ever used by Visual =
Basic=20
> Programmers).
>=20
> Thanks for the reply anyway.
>=20
>=20
> Dominic

You only need to download and install the program.
(Include the VB Com object)=20

I think it's fabulous for working with lots of images from within =
Access!
(I just recently discovered it ...)

You can use late binding like
Sub TestIM()
Dim objIM As Object
Dim imgResult

Set objIM =3D CreateObject("ImageMagickObject.MagickImage.1")
imgResult =3D objIM.Convert("C:\bill_meets_gorilla_screen.jpg", =
"-thumbnail", 300, "C:\billthumb.jpg")
'This converts the original image to a smaller one of max 300 pixels

If Err.Number <> 0 Then
MsgBox "Error converting image"
Else
MsgBox "Conversion OK"
End If
Set objIM =3D Nothing
End Sub

I am not trying to convince you but ... ;-)
With a few lines of code you could handle a whole directory (invDir) of =
images, fully automated from within Access !!

'First, read a filelist in an array called aFileList()
---
For i =3D 0 To UBound(aFileList) - 1
imgResult =3D objIM.Convert(invDir & aFileList(i), "-thumbnail", =
"250x250", invDir & "Thumbs\" & aFileList(i))
'Convert all images and put them in a subdir called 'Thumbs'
Next i
---

Arno R