如何自动调整sql数据库中表中图像的大小

发布于 2024-08-15 12:30:48 字数 995 浏览 3 评论 0原文

我有一个问题,我有一个包含一些网上商店产品的数据库。我从 url (domain.com) 加载 2 个图像,一个是缩略图 (product_thumb_image),另一个是完整图像。 (product_full_image)

我使用相同的网址,并通过在图像标签中添加 Height="100" 属性来调整图像大小。我知道这不是正确的方法,但我不知道另一种将图像批量插入网上商店的方法,无需在我的网上商店(virtuemart)后端一张一张地插入图片

我的问题:如何直接在数据库中调整图像大小,而不必加载完整图像大小并拥有它通过 Height="100" 属性调整大小?

下面是数据库的一小部分,也许有人有一个想法来(自动)调整product_thumb_image 表中的图像大小。

INSERT INTO `webshop_vm_product` (`product_id`, `vendor_id`, `product_parent_id`, `product_sku`, `product_s_desc`, `product_desc`, `product_thumb_image`, `product_full_image`)

VALUES
        (945, 1, 0, '36939', NULL, NULL, 'http://www.domain.com/img/i.php?type=i&file=1246615633.png', 'http://www.domain.com/img/i.php?type=i&file=1246615633.png', 'Y', NULL, 'pounds.', NULL, NULL, NULL, 'inches', NULL, 0, NULL, '', NULL, NULL, NULL, 1261509702, 1261516155, 'Kaspersky Anti-virus 2010 OEM 1PC', 0, NULL, '', 0, NULL, NULL, NULL, '14,90', NULL, NULL);

I have a question, I have a database with some webshop products. I load 2 images from a url (domain.com) one is for the thumb image (product_thumb_image) and the other is a full image. (product_full_image)

I use for both the same url and resize the image by having a Height="100" attribute in the image tag.I know this is not the right way, But I don't know a other way to bulk insert images into a webshop without inserting the pictures one by one in the backend of my webshop (virtuemart)

My question: How can I resize a image directly in the database without having to load the full image size and having it resized by a Height="100" attribute?

Below is a small part of the database, maybe someone has an idea to (auto) resize the image which is in the product_thumb_image table.

INSERT INTO `webshop_vm_product` (`product_id`, `vendor_id`, `product_parent_id`, `product_sku`, `product_s_desc`, `product_desc`, `product_thumb_image`, `product_full_image`)

VALUES
        (945, 1, 0, '36939', NULL, NULL, 'http://www.domain.com/img/i.php?type=i&file=1246615633.png', 'http://www.domain.com/img/i.php?type=i&file=1246615633.png', 'Y', NULL, 'pounds.', NULL, NULL, NULL, 'inches', NULL, 0, NULL, '', NULL, NULL, NULL, 1261509702, 1261516155, 'Kaspersky Anti-virus 2010 OEM 1PC', 0, NULL, '', 0, NULL, NULL, NULL, '14,90', NULL, NULL);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

弄潮 2024-08-22 12:30:48

你不知道。数据库存储东西——它不是图像处理工具。查看图像处理库以了解您正在使用的任何工具包。如果没有可用的,您可以调用 GraphicsMagick 命令。

You don't. The database stores stuff --- it's not an image manipulation tool. Look into an image handling library for whatever toolkits you're using. If none are available, you can probably invoke GraphicsMagick-commands.

同尘 2024-08-22 12:30:48

首先,您的 INSERT 语句有错误,它有 8 列和更多的值。

看来您正在将图像的 URL 存储到数据库中,而不是实际的图像内容?

您必须更改 URL 指向的图像以获得正确的尺寸。您可以制作一个脚本来自动对一堆图像进行调整大小操作,请参阅http://www.imagemagick.org/例如。您的网上商店应用程序可能也有一些用于此目的的工具,希望它的文档有所帮助。

数据库不执行任何类型的图像操作,这是将数据存储到数据库的任何组件的工作。

First of all, your INSERT statement is faulty, it has 8 column and way more values.

It seems that you are storing URLs of images to database, not actual image content?

You must change images pointed by URLs to have right size. You can make a script that make the resize operation for bunch of images automatically, see http://www.imagemagick.org/ for example. You webshop application may also have some tools for this, hopefully it's documentation helps.

Databases do not execute any kind of image manipulation, it is job for what ever component that is storing the data to database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文