title: Magento programmatically add product image
body: <p>I have to create a simple Magento 1.6.x import agent that suppose to create/update products and their images. Could someone advise me how to add product image without having to use the magento API?</p>
  
  <p>The api performance turned out to be very poor and I am starting to be a little frustrated.. :-(</p>
  
  <p>I have found some other questions regarding this problem, but none of them concerns with adding images to the product.</p>
  
  <p>This is what I came with:</p>
  
  <pre><code>$product-&gt;setIsMassupdate(true)
      -&gt;setExcludeUrlRewrite(true)
      -&gt;setManufacturer($this-&gt;addManufacturers(utf8_encode($record[4])))
      -&gt;setSku($record[3])
      -&gt;setAttributeSetId($this-&gt;attribute_set)# 9 is for default
      -&gt;setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
      -&gt;setName(utf8_encode($record[5]))
      -&gt;setCategoryIds($this-&gt;getCategories(array($record[0], $record[1], $record[2]))) # some cat id's,
      -&gt;setWebsiteIDs(array(1)) # Website id, 1 is default
      -&gt;setDescription(utf8_encode($record[6]))
      -&gt;setShortDescription($this-&gt;shortText(utf8_encode($record[6]), 150))
      -&gt;setPrice($price) # Set some price
      -&gt;setSpecialPrice($special_price)
      -&gt;setWeight($record[12])
      -&gt;setStatus( Mage_Catalog_Model_Product_Status::STATUS_ENABLED )
      -&gt;setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
      -&gt;setTaxClassId(2)     // default tax class
      -&gt;setPixmaniaimg($record[10])
      -&gt;setStockData(array('is_in_stock' =&gt; $inStock, 'qty' =&gt; $qty))
      -&gt;setCreatedAt(strtotime('now'));
  </code></pre>
  
  <p>Can someone help me with adding images directly without the API?</p>
  
  <p>Thanks</p>
  
  <p>Lukas</p>