function miniaturka( $source_file, $destination_file, $max_dimension) { $aspect_ratio = $img_width / $img_height; if ( ($img_width > $max_dimension) || ($img_height > $max_dimension) ) // If either dimension is too big... { if ( $img_width > $img_height ) // For wide images... { $new_width = $max_dimension; $new_height = $new_width / $aspect_ratio; } elseif ( $img_width < $img_height ) // For tall images... { $new_height = $max_dimension; $new_width = $new_height * $aspect_ratio; } elseif ( $img_width == $img_height ) // For square images... { $new_width = $max_dimension; $new_height = $max_dimension; } } else { $new_width = $img_width; $new_height = $img_height; } // If it's already smaller, don't change the size. // Make sure these are integers. $thumbnail = imagecreatetruecolor($new_width,$new_height); // Creates a new image in memory. // The following block retrieves the source file. It assumes the filename extensions match the file's format. { $img_source = imagecreatefromjpeg($source_file); } // Here we resample and create the new jpeg. imagecopyresampled($thumbnail, $img_source, 0, 0, 0, 0, $new_width, $new_height, $img_width, $img_height); imagejpeg( $thumbnail, $destination_file, 100 ); // Finally, we destroy the two images in memory. imagedestroy($img_source); imagedestroy($thumbnail); }
Wie ktoś co może być tego powodem...