Home » Magento

Magento: Rotate image

19 March 2010 Share/Bookmark

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

email

php magento mukesh chapagain

Get New Post by Email
RSS Feed Subscribe RSS Feed
  • http://pulse.yahoo.com/_WXBKP2HWPEQSC2PMV5ALZUM3VM -OM KUKUY-

    Excuse me, I wanted to ask, how to make rotate image in PHP or HTML?
    please reply :(

    –Thank You Very Much–