SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Black background in my thumbnails?!?!

    When I generates thumnails like this:

    PHP Code:
    $save $targetPath."thumb_" $imagepath//This is the new file you saving
    $file $targetPath."".$imagepath//This is the original file

    list($width$height) = getimagesize($file) ; 

    if(
    $width $height){
        
    $modwidth 90;
        
    $diff $width $modwidth;
        
    $modheight $height $diff;
    } else {
        
    $modheight 90;
        
    $diff $height $modheight;
        
    $modwidth $width $diff;
    }

    $diff $width $modwidth;

    $modheight $height $diff
    $tn imagecreatetruecolor($modwidth$modheight) ; 
    $image imagecreatefromjpeg($file) ; 
    imagecopyresampled($tn$image0000$modwidth$modheight$width$height) ; 

    imagejpeg($tn$save100); 
    ... it comes out with a black background... Is it possible to make this background white or even better, transparent?

    Thanks...

  2. #2
    SitePoint Enthusiast primozc's Avatar
    Join Date
    Nov 2008
    Location
    Slovenia, EU
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't make sense to me, because if you are making thumbnail with the same aspect ratio as the original image, you shouldn't see the black border at all.

    Nevertheless, maybe you can find those functions helpful:
    Alpha blending: http://si2.php.net/manual/en/functio...hablending.php
    Filling image with solid color: http://si2.php.net/manual/en/function.imagefill.php


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •