I\'m trying to save to file a resized image loaded with LoadPicture
. With the following code I load the image and resize it but I now understoo
SOLVED.
As suggested, I used ImageMagick (the following applies to v7.0.2-4).
The following code opens a dialog window to select the image, calls ImageMagickObject OLE, resizes the image and saves it to a new file:
Private Sub CommandButtonImage_Click()
Dim img
Set img = CreateObject("ImageMagickObject.MagickImage")
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.ButtonName = "Submit"
.Title = "Selezionare un'immagine"
.Filters.Add "Image", "*.gif; *.jpg; *.jpeg; *.png", 1
If .Show = -1 Then
' file has been selected
' fit image into image box
Me.Image1.PictureSizeMode = fmPictureSizeModeZoom
' display preview image in an image control
Me.Image1.Picture = LoadPicture(.SelectedItems(1))
' this will resize the selected image keeping the aspect ratio
' but resizing will be done only to fit into the size given
' ('>' sign) and it will set the image name to 'resized.jpg'
img.Convert .SelectedItems(1), "-resize", "300x300>", "c:\resized.jpg"
Else
' something
End If
End With
End Sub
Other ImageMagick resize options.