如何更改从 oracle db 检索的图像的大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6014660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to change the size of the image retrived from the oracle db
提问by zhanjian
Hi: In our oracle db,there is a blob column used to save the images.
您好:在我们的 oracle 数据库中,有一个 blob 列用于保存图像。
Now I have to display them in the web page,so I create a Image.aspx,which will read the binary blob data and write them to the response so I can insert this image using :
现在我必须在网页中显示它们,所以我创建了一个 Image.aspx,它将读取二进制 blob 数据并将它们写入响应,以便我可以使用以下命令插入该图像:
<img src="Image.aspx?id=xx />
However the size(16k,12M?) and the resoution(800x600,4000x1299?) is not sure,so somethime the image may so large,it will cost much time to download,also some images's resolution is more than 2000x2000,so I want to zoom in them to a small scale.
但是尺寸(16k,12M?)和分辨率(800x600,4000x1299?)不确定,所以有时图像可能很大,下载会花费很多时间,还有一些图像的分辨率超过2000x2000,所以我想要将它们放大到小比例。
That's to say I have read the image binary and chagne them to a "Image" object,read its size and change it?
也就是说我已经读取了图像二进制文件并将它们更改为“图像”对象,读取其大小并更改它?
How to make it?
如何制作?
采纳答案by Aaron Digulla
The usual solution is to have three columns in your image table which contain the width, the height and a thumbnail in a reasonable resolution (say scaled to ratio in a 256x256 or 512x512 rectangle).
通常的解决方案是在图像表中包含三列,其中包含具有合理分辨率的宽度、高度和缩略图(比如在 256x256 或 512x512 矩形中按比例缩放)。
That way, you can figure out how big the image will be without the expensive loading and the thumbnail should work in most situations.
这样,您可以在不进行昂贵加载的情况下计算出图像有多大,并且缩略图应该在大多数情况下都可以使用。
回答by Delmonte
Here is the function for resizing a blob image field:
这是用于调整 blob 图像字段大小的函数:
CREATE OR REPLACE FUNCTION resize_img (i_ID INTEGER)
RETURN BLOB
IS
vImageData BLOB;
vSizedImage BLOB;
BEGIN
SELECT img_simbolo_op
INTO vImageData
FROM tbl_yourtable
WHERE my_ID = i_ID;
DBMS_Lob.createTemporary(vSizedImage, FALSE, DBMS_LOB.CALL);
ORDSYS.OrdImage.processCopy(vImageData, 'maxScale=75 75', vSizedImage);
return vSizedImage;
END resize_img;
回答by Gary Myers
You can use Oracle built-insto rescale/size the image But you'd have to use the BLOB in a constructor for an ORDImage. Then get the Ordimage propertieswhich might be a bit of a strain.
您可以使用 Oracle内置程序来重新缩放/调整图像的大小,但是您必须在 ORDImage 的构造函数中使用 BLOB。然后获取可能有点紧张的 Ordimage 属性。