I'm using FoomanPDF on a Magento 1.9 shop. In the mypdf file i found the following function:

        if ($productImage
        && $productImage != "no_selection"
        && file_exists(Mage::getBaseDir('media').$imagePath)
    ) {
        $imageAttr = $product->getImage() ? 'image' : 'small_image';
        $imageHelper = Mage::helper('catalog/image')->init($product, $imageAttr)->resize(100);
        return (string)$imageHelper;

However this way of adding the images becomes utterly slow when you have more then 5 products in a single PDF. Is there a way to improve the speed? Or make sure Magento is not resizing the initial 1920x1080 images into some small 500px image? I think it's using up a large amount of memory this way.Result, 504, gateway timeout!

Any thoughts?

1 Answer 1


Each time the catalog/image resize function is called, Magento will check the image cache and generate the image if the image doesn't exist.

Best way to avoid performance issues, in my experience would be to find your thumbnail size in your app/design/your_theme/catalog/list.phtml and add this into your Fooman PDF code.

Or, if not defined in list.phtml, goto Magento admin, System -> Configuration -> Catalog -> Product Image -> Small Image Width.

e.g your list.phtml thumbnail is 500px, then use

$imageHelper = Mage::helper('catalog/image')->init($product, $imageAttr)->resize(500);

Your Answer

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

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