开发者

magento: Resize image during upload to desired dimensions

开发者 https://www.devze.com 2023-03-14 05:05 出处:网络
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 no

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

0

精彩评论

暂无评论...
验证码 换一张
取 消