0

How i can first resize then crop image. I already use Varien_Image like this :

        $imageObj = new Varien_Image($_imageUrl);
        $imageObj->constrainOnly(false);
        $imageObj->keepAspectRatio(false);
        $imageObj->keepFrame(false);
        $imageObj->crop($cutH, $cut, $cut,$cutH);
        $imageObj->resize(floor($width), floor($height));
        $imageObj->save($_imageUrl);
        return $imageUrl;

th code above first crop then resize. but i want first resize then crop and also i want only resize width not height?

0

Change the sequence of calling method crop and resize as below

$imageObj = new Varien_Image($_imageUrl);
        $imageObj->constrainOnly(false);
        $imageObj->keepAspectRatio(false);
        $imageObj->keepFrame(false);
        $imageObj->resize(floor($width), floor($height));
        $imageObj->crop($cutH, $cut, $cut,$cutH);
        $imageObj->save($_imageUrl);
        return $imageUrl;
  • I did it before, this will show error of not correct size – Alireza Rahmani Nov 23 '15 at 10:18
  • Try crop with hardcoded values like crop(10, 20, 30, 40) and check if you are still getting the same error. – Anshu Mishra Nov 23 '15 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.