php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32323 imagecreatefromjpeg only black picture
Submitted: 2005-03-15 19:57 UTC Modified: 2005-03-17 10:35 UTC
From: bavaglino at west dot de Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 4.3.10 OS: Linux infong 2.4 #1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bavaglino at west dot de
New email:
PHP Version: OS:

 

 [2005-03-15 19:57 UTC] bavaglino at west dot de
Description:
------------
I have a picture upload which upload the original file and a thumbnail pic. it works fine, but when i use a picture for example with 180DPI and 3000 x 2000 Pixel, the created thumbnail is only black.

with a smaller resolution it works fine.

Reproduce code:
---------------
 $image = imagecreatefromjpeg( $bildlink.'/'.$dateiname2 ) ;
imagecopyresampled($image, $image_norm, 0,0, 0,0,200,$hoehe_norm,$breite,$hoehe);
imagejpeg($image_norm, $bildlink.'/'.$dateiname2_norm , 100 ); 

Expected result:
----------------
i want to see the picture in a smaller version but not a black  picture.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-15 20:23 UTC] bavaglino at west dot de
i changed $image_norm with $image now it's correct for this post, but still larger pictures only thumbnails in black.

imagecopyresampled($image_norm, $image, 0,0, 0,0,200,$hoehe_norm,$breite,$hoehe);
 [2005-03-15 21:51 UTC] pajoye@php.net
Please provide the original image. Use a simple script without dynamic values, something like the sample available at  http://de3.php.net/imagecopyresampled

--Pierre
 [2005-03-16 13:58 UTC] bavaglino at west dot de
ok here we go.

i made a few test with different sizes of pictures.
above 2900 x 1933 pixel the thumbnail is only black.

i use this code for upload the picture:
--------------------------------------------------
###links zum Uploadverzeichnis###
$bildlink = "thumbs" ;

$dateiname = $_FILES['datei']['name'] ;
$dateitype = $_FILES['datei']['type'] ;
$dateisize = $_FILES['datei']['size'] ;

if (empty($dateiname)) {$fehlermeldung = ''.$TEXT['FILENAME'].'' ; }

elseif ( $dateisize > '5240000') {$fehlermeldung = ''.$TEXT['FILESIZE'].'' ; }

elseif ( strlen( $dateiname ) > '25')
{    
$dateinamengroesse = strlen($dateiname) - 25 ;
$fehlermeldung = ''.$TEXT['FILELAENGE'].'' ;
}
    
  elseif ( $dateitype == 'image/jpeg' || $dateitype == 'image/pjpeg' ) {
  
    ## umwandeln von umlauten ##
    $dateiname1 = strtr("$dateiname", " ????", "_aous") ;
    
    ## umwandeln in kleinbuchstaben ##
    $dateiname2 = strtolower("$dateiname1") ;

    $bildteil = split("[.]",$dateiname2) ;
    $dateivorhanden = file_exists($bildlink.'/'.$bildteil[0].'_norm.'.$bildteil[1]) ;

if ($dateivorhanden) {$fehlermeldung = ''.$TEXT['FILEEXIST'].'' ;}

    else {
      ## originalbild uploaden ##
      move_uploaded_file( $datei , $bildlink.'/'.$dateiname2 ) ;

      ## wie gro? ist das originalbild ##
      $gross = getimagesize( $bildlink.'/'.$dateiname2 ) ;
      $breite = $gross[0] ;
      $hoehe = $gross[1] ;
      $typ = $gross[2] ;

      $hoehe_norm = $hoehe * 200 / $breite ;
      $image_norm = imagecreatetruecolor( 200 , $hoehe_norm ) ;

      ## neuen namen f?rs thumbnail vergeben ##
      $bild_s = split("[.]",$dateiname2);
      $dateiname2_norm = $bild_s[0].'_norm.'.$bild_s[1] ;

      ## thumbnail erstellen ##
      $image_norm = imagecreatetruecolor(200, $hoehe_norm);
      $image = imagecreatefromjpeg( $bildlink.'/'.$dateiname2 ) ;
        imagecopyresampled($image_norm, $image, 0,0, 0,0,200,$hoehe_norm,$breite,$hoehe);
      imagejpeg($image_norm, $bildlink.'/'.$dateiname2_norm , 100 );

      $fehlermeldung = ''.$TEXT['FILEDONE'].'' ;
    }
  }
   else {$fehlermeldung = ''.$TEXT['FILEDONEERROR'].'';
  }
} 
-------------------------------------------------

please download example pictures here:

original picture with 3072 pixel:
http://www.klixx.com/picsearch/thumbs/testbild_3072.jpg

example picture with 2600 pixel:
http://www.klixx.com/picsearch/thumbs/testbild_2600.jpg

example picture with 2900 pixel:
http://www.klixx.com/picsearch/thumbs/testbild_2900.jpg

thanks for help
 [2005-03-17 10:35 UTC] pajoye@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Even if you think it is not a bug, we often know better than you,
please consult the support channels first before even considering
to reopen this report.

Thank you for your interest in PHP.

testbild_2900.jpg is a correct jpeg and imagecopyresamples works with an image created using it. The two others are broken.

--Pierre
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 01:00:02 2025 UTC