Here goes the code:
$mainImage = Mage::getBaseDir('media') . DS . 'test' . DS . 'sample.jpg'; $image = new Varien_Image($mainImage); // crop image $image->crop(10, 10, 10, 10); // crop(top, left, $right, $bottom) $image->save(Mage::getBaseDir('media'). DS . 'test' . DS . 'new.jpg');Code Explanation:
In the code above, you can see that I have an image named sample.jpg inside media/test/ directory.
At first, I have cropped the image by 10px from top, left, bottom, and right side.
The new cropped image is saved inside media/test/ directory as new.jpg.
No comments:
Post a Comment