Hii
try using the below function in your file
public static function copyImg($id_entity, $id_image, $sourcePath, $entity = 'products', $regenerate = true) {
$watermark_types = explode(',', Configuration::get('WATERMARK_TYPES'));
switch ($entity) {
default:
case 'products':
$image_obj = new Image($id_image);
$path = $image_obj->getPathForCreation();
break;
case 'categories':
$path = _PS_CAT_IMG_DIR_ . (int) $id_entity;
break;
case 'manufacturers':
$path = _PS_MANU_IMG_DIR_ . (int) $id_entity;
break;
case 'suppliers':
$path = _PS_SUPP_IMG_DIR_ . (int) $id_entity;
break;
}
ImageManager::resize($sourcePath, $path . '.jpg');
$images_types = ImageType::getImagesTypes($entity);
if ($regenerate) {
foreach ($images_types as $image_type) {
ImageManager::resize($sourcePath, $path . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height']);
if (in_array($image_type['id_image_type'], $watermark_types))
Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity));
}
}
return true;
}