Magento: Add image attribute of product

By using this you can create image attribute in product which is different as image gallery. It helps to tag the image over main image of product.

Mysql setup file

<?php
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$setup->addAttribute('catalog_product', 'tag_image', array(
	'type'              => 'varchar',
	'backend'           => 'catalog/product_attribute_backend_image',
	'frontend'          => '',
	'label'             => 'Tag Image',
	'input'             => 'image',
	'class'             => '',
	'source'            => '',
	'global'            => 0,
	'visible'           => 1,
	'required'          => 0,
	'user_defined'      => 0,
	'default'           => '',
	'searchable'        => 0,
	'filterable'        => 0,
	'comparable'        => 0,
	'visible_on_front'  => 1,
	'unique'            => 0,
	'position'          => 0,
	'group' => 'General',
	));

$installer->endSetup();
?>

Mage Model

<?php
class Mage_Catalog_Model_Product_Attribute_Backend_Image extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
{

    /**
     * Save uploaded file and set its name to category
     *
     * @param Varien_Object $object
     */
    public function afterSave($object)
    {
        $value = $object->getData($this->getAttribute()->getName());

        if (is_array($value) && !empty($value['delete'])) {
            $object->setData($this->getAttribute()->getName(), '');
            $this->getAttribute()->getEntity()
                ->saveAttribute($object, $this->getAttribute()->getName());
            return;
        }

        $path = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product' . DS;

        try {
            $uploader = new Varien_File_Uploader($this->getAttribute()->getName());
            $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
            $uploader->setAllowRenameFiles(true);
            $uploader->save($path);

            $object->setData($this->getAttribute()->getName(), $uploader->getUploadedFileName());
            $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
        } catch (Exception $e) {
            if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
                Mage::logException($e);
            }

            return;
        }
    }
}

?>