I'm sorry to say, but behind the scenes with magento images, there is more to it than just pasting the file name into the database and linking to your image. Generating a cache in itself is quite complicated. I find it difficult for you to do it the way you try.
Having said that, I have a suggestion. Since your images are already on the server, I suggest you write a simple php script to tell magento to attach them to the product image. It can be automated, but I will give you a small example below ...
To attach an image, you simply go to a URL like this http://yoursite.com/imageattacher.php?sku=YOURSKU&image=yourimagefilename.jpg
The script will look like this: create a file in your purple ROOT and name it imageattacher.php. Upload images to the magento media import directory. I have not tested this, but it should work.
<?php // Initialize magento for use outside of core umask(0); require_once 'app/Mage.php'; Mage::app('admin'); // Get the variables from the URL $sku = $_GET["sku"]; $imageName = $_GET["image"]; // get the image from the import dir $import = Mage::getBaseDir('media') . DS . 'import/' . $imageName; // Load the product by sku $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku); // if the product exists, attempt to add the image to it for all three items if ($product->getId() > 0) { // Add the images and set them for their respective usage (the radio button in admin) $product->addImageToMediaGallery($import,array('image', 'small_image', 'thumbnail'),false,false); // Make the changes stick $product->save(); } ?>
See http://www.danneh.org/2012/05/creating-products-programmatically-magento/
source share