Programmatically add image to product in magento
devm.com.np
<?php
$productId 
Mage::getModel('catalog/product')->getIdBySku('sku');
$product Mage::getModel('catalog/product')->load($productId);
        
$mediaAttribute = array (
                                
'thumbnail',
                                
'small_image',
                                
'image'
                                
);


$imageUrl '';    
$destinationFilepath '';    

$mediaGalleryAttribute Mage::getModel('catalog/resource_eav_attribute')->loadByCode('catalog_product''media_gallery');

foreach (
$product->getMediaGallery('images') as $image) {
       
$mediaGalleryAttribute->getBackend()->removeImage($product$image->getFile());
    }

try{
    
$adapterGd2 = new Varien_Image_Adapter_Gd2();
    
$adapterGd2->open($imageUrl);
    
$adapterGd2->save($destinationFilepath);
    
    
$product->addImageToMediaGallery($destinationFilepath$mediaAttributefalsefalse);
    
    
unlink($destinationFilepath);    
}
catch(
Exception $e)
{
    
}
?>