Jump to content

Random Failures To Load Thumbnails - IE7 & FireFox


RAH

Recommended Posts

Good idea but that's not the case.  You can upload 10 jpgs and 3 of the thumbnails will randomly fail to load.  I mean if you refresh enough you can sometimes get thumbnails which previously failed to load working again.  Also it works 100% in Opera all the time.

Hi,

 

Here's two files, think they are relevant:

 

<?
set_time_limit(0);

function ImageCopyResampleBicubic ($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
{
        for ($i = 0; $i < 4; $i++) { // get pallete. Is this algoritm correct?
                $colors = ImageColorsForIndex ($src_img, $i);
                ImageColorAllocate ($dst_img, $colors['red'], $colors['green'], $colors['blue']);
        }

        $scaleX = ($src_w - 1) / $dst_w;
        $scaleY = ($src_h - 1) / $dst_h;

        $scaleX2 = $scaleX / 2.0;
        $scaleY2 = $scaleY / 2.0;

        for ($j = $src_y; $j < $dst_h; $j++) {
                $sY = $j * $scaleY;

                for ($i = $src_x; $i < $dst_w; $i++) {
                        $sX = $i * $scaleX;

                        $c1 = ImageColorsForIndex ($src_img, ImageColorAt ($src_img, (int) $sX, (int) $sY + $scaleY2));
                        $c2 = ImageColorsForIndex ($src_img, ImageColorAt ($src_img, (int) $sX, (int) $sY));
                        $c3 = ImageColorsForIndex ($src_img, ImageColorAt ($src_img, (int) $sX + $scaleX2, (int) $sY + $scaleY2));
                        $c4 = ImageColorsForIndex ($src_img, ImageColorAt ($src_img, (int) $sX + $scaleX2, (int) $sY));

                        $red = (int) (($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) / 4);
                        $green = (int) (($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) / 4);
                        $blue = (int) (($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) / 4);

                        $color = ImageColorClosest ($dst_img, $red, $green, $blue);
                        ImageSetPixel ($dst_img, $i + $dst_x, $j + $dst_y, $color);
                }
        }
}

$a=300;
$file=$_GET['src'];


$is = getimagesize ($file);
$w0 = $is[0];
$h0 = $is[1];

//if($w0 >= $h0){        $w1 = $a;        $h1 = ceil( $a * $h0 / $w0 ); }
// else {        $h1 = $a;        $w1 = ceil( $a * $w0 / $h0 ); }

$w1=$a;
$h1=ceil($a*$h0/$w0);

if(strtolower(substr($file,-3))=="jpg"){
        $src = ImageCreateFromJPEG($file);
        $type="jpg";
}
if(strtolower(substr($file,-3))=="gif"){
        $src = ImageCreateFromGIF($file);
        $type="gif";
}
if(strtolower(substr($file,-3))=="png"){
        $src = ImageCreateFromPNG($file);
        $type="gif";
}

$dst=ImageCreate($w1,$h1);
$tmp=ImageColorAllocate($dst,255,255,255);
$transp=ImageColorAt($dst,1,1);
ImageColorTransparent($dst,$transp);
$transp=ImageColorAt($src,1,1);
ImageColorTransparent($src,$transp);
ImageCopyResampled($dst,$src,0,0,0,0,$w1,$h1,$w0,$h0);

header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Last-Modified: " . date("D, d M Y H:i:s") . " GMT");

header("Content-type: image/jpeg");
ImageJPEG($dst,$file,70);
?>

 

<?
   $open = $_GET['open'];
   $file_self = sqlr("SELECT thumbnail FROM `file_items` WHERE md5(id)='".$open."'");
   //$file_url = sqlr("SELECT link FROM `files` WHERE md5(id)='".$open."'");

     $file_path="thumbnails/$file_self";
     $download_size = filesize($file_path);
     header("Content-type: application/x-download");
     header("Content-Disposition: attachment; filename=$file_self;");
     header("Accept-Ranges: bytes");
     header("Content-Length: $download_size");
     readfile($file_path);

?>

Hi,

 

Here's the relevant bits of the template coding:

 

<head>
<style type="text/css">
.style3 {
color: #FF0000;
}
.style4 {
text-align: center;
line-height: 100%;
margin-top: 0;
margin-bottom: 0;
}
.style5 {
text-align: center;
}
</style>
</head>

<table width="100%" border="0" cellspacing=0 cellpadding=0>

  <tr>

            <td valign=top width="500">




      <H3 class=style5>



      <A href="%=link_mode%">
	<IMG alt="%=title%" src="%=link_thumbnail%" border=0></A></H3>
	<H3 class=style5>

 

 

Any ideas?

 

Thanks.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.