Mobile-Menu iFuturz Infoweb Inc. Contact Portfolio

02

Oct

Resize products and categories images using ImageMagick in Oscommerce

Resize products and categories images using ImageMagick in Oscommerce

Posted On : October 2, 2013

| 2 Comments

Imagick is a native php extension used to create and modify images using the ImageMagick API. It can read, convert and write images in a variety of formats.

If you have a very large oscommerce store with large products and categories images and you need to fit these images on 150×150(px) space in your website. Then you can just set the width and height attributes to 150 on the image tag in your HTML and display it. This will work perfectly fine but it will effect page loading time and performance

The better solution is resize the images in 150px x 150px and then use it in your oscommerce site.

In this tutorial we are going to describe how can you resize your oscommerce store products and categories images using simple imagemagick functions.

First you need to install ImageMagick on your server.

Now open the admin/includes/functions/ directory and open the general.php file and add the following code at the end of file.

function tep_makethumbnailimage($src, $width, $height)
{
	$img = new Imagick($src);
	$img->thumbnailImage($width, $height);
	$img->writeImage($src); 
}

Next open the admin/categories.php and find the following code.

 
$products_image_name = $products_image->filename;

Add the following code just below the code.

tep_makethumbnailimage(DIR_FS_CATALOG_IMAGES . $products_image_name, 150, 150);

This will resize products image to 150px x 150px.For resize categories image find the following code

if ($categories_image->parse() && $categories_image->save()) {

Add the following code just below it

$categories_image_name = $categories_image->filename;
tep_makethumbnailimage(DIR_FS_CATALOG_IMAGES . $ categories_image_name, 150, 150);
  • Tags:

Comment

Posts

  • Hi! I’ve been reading your weblog for a long time now and finally decided to give you a shout out from Dallas Texas! Just wanted to say keep up the fantastic job!

    Bernadine

    • Thankyou Bernadine, its good to hear from you. Feel free to say whatever and whenever you like

      iFuturz