Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Image Resize works but a white background appears!


Guest

Recommended Posts

Hi again!

 

I changed the internal code in output_html like this:

 

////

// The HTML image wrapper function

function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {

if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {

return false;

}

if ( ($width == SMALL_IMAGE_WIDTH && $height == SMALL_IMAGE_HEIGHT) || $resample ) {

include DIR_FS_CATALOG . "/" . DIR_WS_FUNCTIONS . "image_resample.php";

}

// alt is added to the img tag even if it is null to prevent browsers from outputting

 

 

Then I use this script:

 

<?php

/*

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

*/

 

/*

The filename for the generated image needs to be different since we

don't want to change the original. Meaning you can alter size in admin

and get new resamples from the original.

 

REQUIRES netpbm and netpbm-progs in path

Made and tested on Linux RH7.3

 

-J?rg ([email protected])

*/

 

// the name of the resampled image

$file = eregi_replace( '.([a-z]{3,4})$', "-{$width}x{$height}.1", $src );

 

// if this file does not exist, then make it

if( !is_file( $file ) ) {

$src = DIR_FS_CATALOG . '/' . $src; // original picture to be resized

$dst = DIR_FS_CATALOG . '/' . $file; // name of the resamplee (ie. pathimage-78x88.jpg )

$i = getimagesize( $src ); // need to know type

switch ( $i[2] ) {

case 3: // PNG

$cmd = "pngtopnm '$src'|pnmscale -xysize $width $height|ppmquant 255|pnmtopng $trans > '$dst'";

break;

case 1: // GIF

$cmd = "giftopnm '$src'|pnmscale -xysize $width $height|ppmquant 255|ppmtogif $trans > '$dst'";

break;

case 2: // JPG

$cmd = "djpeg '$src'|pnmscale -xysize $width $height|cjpeg -quality 90 > '$dst'";

break;

}

$res = exec( $cmd ); // Do the actual operation

}

$src = $file; // Use the resampled image

$width = $height = ""; // and it's own properties

?>

 

The result is:

 

screenshot.jpg

 

 

As you can see the backgound of two resampled images (the green one)

have a white backgound and not transparent.

 

Take a better look here: http://www.xtrasat.co.uk/shopping/catalog/

 

How can I change this so that the background is getting transparent?

 

 

Best regards,

 

Leon

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...