Help - Search - Member List - Calendar
Full Version: resolution/size in thumbnail?
Krazy Letter Forums > Members stuff > Computer Programs > PHPKImageHost > Help!
subc
I was wondering about this... is it possible to somehow generate a small black bar at the bottom of thumbs that contains the size and resolution of the full sized images?

Also, I've been looking inside many of the php files, but maybe I missed it. What value (and in what file) controls the amount of compression applied to thumbnails? I would really like to increase compression.

thanks
subc
I ask about the compression because sometimes it doesn't make sense to post a thumbnail, such as:

user posted image

the thumbnail is 19.95KB, while the full size image (original png) is only 7.56KB bonk.gif

thanks again
subc
corrected thumb: user posted image
subc
ok, scrap it. i think I'm gonna have to stop using this script sad.gif
I keep getting error messages about the database for no apparent reason (and there's nothing wrong with the dbase).

well, it was interesting. time to search for something else. many thanks.
subc
ok, I take my previous message back tongue.gif

I think I figured out what the problem was, so I will explain for thos who might have the same problem.

When I first installed the script, I did not wanted to create a table from the cpanel just to test it, so I just used a mysql dbase I already had (and have) with phpbb on it.
I sai to myself "well, it will only create 3 tables, so what the heck. I can delete them if it doesn't work..."

So up to here everything is fine. And then I decided that I liked the script, and I moved the tables to a new database... but here's the issue: I created a new mysql dbase keeping the same username used in the phpbb dbase.

And basically that's the problem. It appears that phpbb receives a lot of automated visits by scripts, bots and what not, so the username used for that dbase was constantly beign used, and that caused timeout and excessive connections to mysql errors on the image hosting script.

needless to say, I realized this when I started using another script with the same username and noticed errors too. that's when I realized the possible cause and quickly went back to this script and fixed things (created a new username for it's own mysql database). As soon as I did that, all the problems magically dissapeared ohmy.gif

and btw, I went back to JPEG tongue.gif just so the user is able to 'save image as..' with the right extensions for GIF and PNG.
subc
found this code for another script, and it adds a 1px black border all around thumbnail and also adds a small bar (15px high) at bottom of thumbnail with image size and dimentions:

the upload.php file has some code that reads:

PHP
            // create thumbnails?
            if ( $create_thumbs && is_image ( $dest_path, true ) )
            {
                $image_inf = getimagesize ( $dest_path );
                $image_ratio = $image_inf[1] / $image_inf[0];
                $new_width = $UPL['CONFIGS']['THUMBNAIL_WIDTH'];
                $new_height= ceil ( $new_width * $image_ratio );
                $thumb_name = get_filename ( $dest_path ) . '_thumb.' . get_extension ( $dest_path );
                $thumb_created = true;
                $thumb_url = $UPL['SETTINGS']['userfiles_url'] . $UPL['USER']['id'] . '/' . ( $upload_to != '' ? $upload_to . '/' : '' ) . rawurlencode ( basename ( $thumb_name ) );
                /*
                Check the filesize of the full sized image and send it to img_resize so it can
                be added onto the thumbnail

                By Chick3n
                */
                $fsize = round(filesize($dest_path)/1024,0);
                if ( img_resize ( $dest_path, $thumb_name, $new_width, $new_height, $fsize ) )
                {
                    $space_used += filesize ( $thumb_name );
                }
            }
            else
            {
                $thumb_created = false;
                $thumb_url = '';
            }


another file named 'functions.php' has some code that reads:

PHP
function img_resize ( $src, $dst, $width, $height, $fsize )
{
    $img_inf = @getimagesize ( $src );

    if ( is_array ( $img_inf ) )
    {
        $im_src = importimage ( $src, $img_inf[2] );
        if ( $im_src === false ) return false;

        /*
        The following code makes the image 15pixels taller and adds a 1px border
        around every edge. It then adds a black box to the bottom (15px high)
        and adds text detailing the size of the image and its dimensions
        Make sure you upload arial.ttf to the same folder as "upload.php"
        (not the includes folder)

        Thanks to MarcelG for pointing out some of my errors (and fixing one :))
        By Chick3n
        */
        $resheight = $height;
        $height = $height+15;
        $im_dst = ImageCreateTrueColor ( $width, $height );
        ImageCopyResampled ( $im_dst, $im_src, 0, 0, 0, 0, $width, $resheight, $img_inf[0], $img_inf[1] );

        $black = ImageColorAllocate($im_dst, 0, 0, 0);

        imageline($im_dst,0,0,$width,0,$black); #top
        imageline($im_dst,0,$height-1,$width,$height-1,$black); #bottom
        imageline($im_dst,0,0,0,$height,$black); #left
        imageline($im_dst,$width-1,0,$width-1,$height,$black); #right

        $white = ImageColorAllocate($im_dst, 255, 255, 255);
        imagefilledrectangle($im_dst,0,$height-15,$width-1,$height,$black);
        $font = "arial.ttf";
        $size = 9;
        $string = $img_inf[0]."x".$img_inf[1]."  ".$fsize."kb";
        $bbox = imagettfbbox ($size, 0, $font, $string);
        $textWidth = $bbox[2] - $bbox[0];
        $hwidth = floor($width/2);
        $textpos = $hwidth-ceil($textWidth/2);
        imagettftext($im_dst,$size,0,$textpos,$height-3,$white,$font,$string);
        /*
        End custom code :)
        */

        $retval = exportimage ( $im_dst, $img_inf[2], $dst );
        imagedestroy ( $im_src );
        imagedestroy ( $im_dst );
        return $retval;
    }
    return false;


could that be helpful at all for the topic of this thread? ohmy.gif
lappy512
I'll see about the compession and adding the black borders in the next version. Thanks! smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.