Generuje sobie miniaturkę... Wszystko jest super ekstra do chwili kiedy podglądam sobie plik a tu... BLACK, nie ma nic tylko czarny ekran...
  1. function miniaturka( $source_file, $destination_file, $max_dimension)
  2. {
  3. list($img_width,$img_height) = getimagesize($source_file); // Get the original dimentions
  4. $aspect_ratio = $img_width / $img_height;
  5.  
  6. if ( ($img_width > $max_dimension) || ($img_height > $max_dimension) ) // If either dimension is too big...
  7. {
  8. if ( $img_width > $img_height ) // For wide images...
  9. {
  10. $new_width = $max_dimension;
  11. $new_height = $new_width / $aspect_ratio;
  12. }
  13. elseif ( $img_width < $img_height ) // For tall images...
  14. {
  15. $new_height = $max_dimension;
  16. $new_width = $new_height * $aspect_ratio;
  17. }
  18. elseif ( $img_width == $img_height ) // For square images...
  19. {
  20. $new_width = $max_dimension;
  21. $new_height = $max_dimension;
  22. }
  23. else { echo "Error reading image size."; return FALSE; }
  24. }
  25. else { $new_width = $img_width; $new_height = $img_height; } // If it's already smaller, don't change the size.
  26.  
  27. // Make sure these are integers.
  28. $new_width = intval($new_width);
  29. $new_height = intval($new_height);
  30.  
  31. $thumbnail = imagecreatetruecolor($new_width,$new_height); // Creates a new image in memory.
  32.  
  33. // The following block retrieves the source file. It assumes the filename extensions match the file's format.
  34. if ( strpos($source_file,".gif") ) { $img_source = imagecreatefromgif($source_file); }
  35. if ( (strpos($source_file,".jpg")) || (strpos($source_file,".jpeg")) )
  36. { $img_source = imagecreatefromjpeg($source_file); }
  37. if ( strpos($source_file,".bmp") ) { $img_source = imagecreatefromwbmp($source_file); }
  38. if ( strpos($source_file,".png") ) { $img_source = imagecreatefrompng($source_file); }
  39.  
  40. // Here we resample and create the new jpeg.
  41. imagecopyresampled($thumbnail, $img_source, 0, 0, 0, 0, $new_width, $new_height, $img_width, $img_height);
  42. imagejpeg( $thumbnail, $destination_file, 100 );
  43.  
  44. // Finally, we destroy the two images in memory.
  45. imagedestroy($img_source);
  46. imagedestroy($thumbnail);
  47. }

Wie ktoś co może być tego powodem...