Magento: Rotate image
Here is a quick tip to rotate image to any degree of your choice in Magento. The rotate function of Varien_Image does the magic :)
Here goes the code:
$mainImage = Mage::getBaseDir('media') . DS . 'test' . DS . 'image.jpg';
$image = new Varien_Image($mainImage);
// rotate image with the angle of your choice
// rotate($angle)
$image->rotate(90);
// save the image
$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 image.jpg inside media/test/ directory.
Then I have rotated the image to 90 degree.
The new rotated image is saved inside media/test/ directory as new.jpg.
Hope this helps and thanks for reading.
From Mukesh Chapagain's Blog, post Magento: Rotate image
Related posts:
- Magento: Create Watermark Image
- Magento: Crop image
- Magento: Get width height of image using Varien_Image class
- jQuery: Grey out background and preview image as popup
- Magento: Custom function to resize image proportionally
- Magento: Resize Image
- Magento: Get height and width of Image
- jQuery: Preview Image with Tooltip Effect
- jQuery: Preview Image with Zoom Effect
- jQuery: Animate and Transfer effect with Image
