Access 2016将图片大小限制为600x800 [英] Access 2016 restrict picture size to 600x800
问题描述
我正在建立数据库,遇到一个需要解决的问题.客户希望该数据库能够将图片链接到特定记录.我有它,所以图片不是OLE对象,而是链接到将位于其网络驱动器上的图片文件夹...因此,基本上,图片将是指向文件路径的超链接....
I am building a database and came across an issue that I need help in resolving. This database the customer wants to be able to link pictures to specific records. I have it so the pics are not OLE objects but links to a picture folder that will be on their network drive...So essentially the picture will be a hyperlink to the file path....
我的问题是有人知道我可以让数据库自动将图片重新格式化为600 x 800大小以帮助节省空间吗?我们都知道,如果我不强迫数据库为他们做的话,那将不会发生,并且可能会吞噬宝贵的空间,因为这个数据库预计会变得很大.因此,我想使图片文件夹尽可能小,以便为数据库留出更多空间.
My question is does anyone know I way I can have the database reformat the picture automatically to 600 x 800 size, to help save space? We all know if I don't force the DB to do it for them it will not happen and potentially eat up valuable space, as this DB is expected to get quite large. So I would like to keep the picture folder as small as possible, giving the database more room.
推荐答案
You can use the WIA libary as shown in VBA – Resize Image like this:
Function ResizeImageTo600x800(ByVal PathToImage As String, ByVal PathToResizedImage As String) As Boolean
Dim WiaImgFile As Object 'WIA.ImageFile
Set WiaImgFile = CreateObject("WIA.ImageFile")
With CreateObject("WIA.ImageProcess") 'WIA.ImageProcess
.Filters.Add .FilterInfos("Scale").FilterID 'Add Scale Filter to ImageProcess
.Filters(1).Properties("MaximumWidth") = 600 ' Set Width to 600px
.Filters(1).Properties("MaximumHeight") = 800 'Set Height to 800px
'.Filters(1).Properties("PreserveAspectRatio") = False ' uncomment if AspectRatio should not be preseved
WiaImgFile.LoadFile PathToImage ' Load Image
.Apply(WiaImgFile).SaveFile PathToResizedImage ' Apply Filter and save resized Image
ResizeImageTo600x800 = True
Set WiaImgFile = Nothing
End With
End Function
用法:
If ResizeImageTo600x800("\\path\to\image", "\\path\to\resized\image") then
Msgbox "ResizeImageTo600x800 successful!"
End If
或者:
ResizeImageTo600x800 "\\path\to\image", "\\path\to\resized\image"
根据图像类型,还可以增加图像压缩率以节省空间.WIA也应支持这一点(使用转换过滤器"及其质量"属性).
Depending on your image types, you may also increase the compression of your image to save space. WIA should support this too (with the Convert Filter and its Quality Property).
这篇关于Access 2016将图片大小限制为600x800的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!