开发者

how to auto resize image in sql database in a table

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);


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜