Skip to content

antoinekociuba/Mbiz_ImageCrop

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Mbiz_ImageCrop

Simple helper to crop and/or resize images in Magento

Howto Crop

<?php
$width = 100; // required argument
$height = 200; // optional argument
$imagePath = 'foo/bar.png'; // Your image is in the /media directory. In /media/foo/ precisely.

// The method of the helper
// crop($imageRelativePath, $width, $height = null);

$imageUrl = Mage::helper('mbiz_imagecrop')->crop($imagePath, $width, $height);

Howto Resize

<?php
$width = 100; // required argument
$height = 200; // optional argument
$imagePath = 'foo/bar.png'; // Your image is in the /media directory. In /media/foo/ precisely.

// The method of the helper
// resize($imageRelativePath, $width, $height = null);

$imageUrl = Mage::helper('mbiz_imagecrop')->resize($imagePath, $width, $height);

You can also set a prefix of the new image directory. The prefix is a directory. By default, our new image will be saved in /media/cache/100x200/hash/b/a/bar.png. But if you set a prefix, like:

<?php
$imageUrl = Mage::helper('mbiz_imagecrop')->setPrefix('baz')->crop($imagePath, $width, $height);

or

<?php
$imageUrl = Mage::helper('mbiz_imagecrop')->setPrefix('baz')->resize($imagePath, $width, $height);

The image will be saved in /media/baz/cache/100x200/hash/b/a/bar.png.

Finally, you can define a custom quality for the newly generated image (95 by default), by using available setter on helper :

<?php
$imageUrl = Mage::helper('mbiz_imagecrop')->setPrefix('baz')->setQuality(80)->resize($imagePath, $width, $height);

Have fun!

About

Simple helper to crop images in Magento

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • PHP 100.0%