I have magento custom script, it is saving "Out of Stock" product's image folder wise. Custom is working fine. But for some products it is saving product back side image which is useless to identify the product. (Please check attached screenshot - result).
We want to save product "Small Image" which is showing in product category page.
Script files are attached to understand better. It is only 15 Minutes work if you understand clearly to change image logic.