I have several hundreds of category Images containing a .png extension. But I want to convert that images to .jpg (outside of Magento and not part of that question) and then reupload them to media/catalog/category and tell Magento to use the new .jpg extension for all .png Category Images. Including Thumbnail Image and Image field.

I found the quite similar Question Migrating All Product Images in Magento from PNGs to JPEGs but the difference is that I want to change Category Images and not Product Images.

Can someone tell me how to change that script or a different approach, please? Updating all Categories in the backend manually would take to much time.

2 Answers 2


Since this is a one time change you may wish to consider taking a SQL approach. This will be quicker, and, if you backup your database before hand, you can do this safely.

Your images for the categories are held in catalog_category_entity_varchar table however you did not say whether these are the main images or the thumbnails. Therefore have a quick search of the table to find out:

SELECT * FROM  `catalog_category_entity_varchar` WHERE  `value` LIKE  '%.png%';

This should return images that you know. Look at the value for attribute_id. This could be something like '45'.

Now you want to run an update, replacing xx with your attribute_id:

UPDATE `catalog_category_entity_varchar` SET `value` = REPLACE(`value`, '.png', '.jpg') WHERE `attribute_id`=xx;

If you are not happy with updating the database directly in a few minutes you could write a Magento module, iterate on the categories and update the image accordingly. However, for a one off the sql approach should work out nicely.


I accepted the mySQL solution as it seems to be the easier one. But we have changed the code of that script in the meantime so I thought why not add this as well.



$storeId = 0;

$category = Mage::getModel ( 'catalog/category' );

$tree = $category->getTreeModel ();

$ids = $tree->getCollection()->getAllIds();

    foreach ($ids as $id) {

        $pk = Mage::getModel('catalog/category');



        $pk->setImage(str_ireplace('.png', '.jpg', $pk->getImage()));
        $pk->setThumbnail(str_ireplace('.png', '.jpg', $pk->getThumbnail()));
        $pk->setImageUrl(str_ireplace('.png', '.jpg', $pk->getImageUrl()));


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.