Home » Magento

Magento: Rotate image

19 March 2010 691 views Popularity: 2% Share/Bookmark

email

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.

Related posts:

  1. Magento: Create Watermark Image
  2. Magento: Crop image
  3. Magento: Get width height of image using Varien_Image class
  4. jQuery: Grey out background and preview image as popup
  5. Magento: Custom function to resize image proportionally
  6. Magento: Resize Image
  7. Magento: Get height and width of Image
  8. jQuery: Preview Image with Tooltip Effect
  9. jQuery: Preview Image with Zoom Effect
  10. jQuery: Animate and Transfer effect with Image
  • 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–