I have been faced with this dreaded issue that many have reported and failed to get working.
My goal is to add images to products by matching SKU with the file, which is basically
$sku . ".jpg"
What I have done was imported a CSV using Magmi, all products were imported and I added images to each media gallery. The images, however, are all set to No Image in the admin panel. see screenshot http://screencloud.net/img/screenshots/b2b8cd4d67e82ff25c5e0ca8d34aef57.png
I created several scripts over the last few days in attempts to remedy the issue, however none of them have been successful. Here is my most recent script: script on gist
The images import fine, they are just not being set to thumbnail or small_image accordingly. I have even truncated the images in the database and physically removed the images to "start fresh" if you will.
I'm already 3 days into this issue and any help would be greatly appreciated, as none of the products show thumbnail or small_image on the frontend, nor the image base at this point.
I could set each image manually on each product, but on a database with 7000 products, it would take an insane amount of time to do each individually. I will also have to repeat this process when we do our next import of 200,000+ skus, so I need to get this working.