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?

1 Answer 1

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;
2
  • I did it before, this will show error of not correct size Commented Nov 23, 2015 at 10:18
  • Try crop with hardcoded values like crop(10, 20, 30, 40) and check if you are still getting the same error. Commented Nov 23, 2015 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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