magento: Resize image during upload to desired dimensions
I want to resize product images before upload them by using values through text boxes. eg: user browse image and then give width(px) in one text and height(px) in another textbox click on apply and now this size is apply on image. then user upload image. can any one tell me or guide me to resource so 开发者_开发知识库i can get this functionality.
i already added both text box with button on product image upload grid.
What is the point? Magento spares you from any of that fooling around with images. You upload them in whatever size you want hen it creates and caches the sizes it needs on the fly. What your trying to achieve is a leap backwards.
Please use this code to resize your image
$imageUrl = "http://localhost/"; $imageResized = Mage::getBaseDir('media').DS."catalog/category/resized";
$imageObj = new Varien_Image($imageUrl);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(false);
$imageObj->keepTransparency(True);
$imageObj->setImageBackgroundColor(false);
$imageObj->backgroundColor(false);
$imageObj->quality(100);
$imageObj->setWatermarkImageOpacity(0);
$imageObj->resize(120, 120); $imageObj->save($imageResized);
I think you have to look at this controller.
Mage_Adminhtml_Catalog_Product_GalleryController
You will need to rewrite this controller. Some how make the width and height values arrive to the action. And than apply re-sizing to the image.
HTH
精彩评论