views:

334

answers:

2

Hello all,

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);
+3  A: 

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.

Alex Brasetvik
+1  A: 

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.

Juha Syrjälä
I see that now, for the insert statement, I just copy/paste a selection, but shortend the columns and not the values, my bad. Storing image url's is at this point the only way to quickly add pictures to my webshop. The only thing is that when a URL is used, the auto resize option is not working of virtuemart. It's only working when you browse for a image on my local drive and insert it. This is a lot of images to process for a whole webshop.
Chris