The name of the newly generated thumbnail $ filename image, including the path
Create a thumbnail for the newly created image
PHP code
- // The file
- $ Filename = 'mm.jpg ';
- $ DstFile = "icons /";
- $ FilePath = "icons/test.jpg ";
- // Set a maximum height and width
- $ Width = 100;
- $ Height = 100;
- // Content type
- Header ('content-type: image/jpeg ');
- // Get new dimensions
- List ($ width_orig, $ height_orig) = getimagesize ($ filename );
- If ($ width & ($ width_orig <$ height_orig )){
- $ Width = ($ height/$ height_orig) * $ width_orig;
- } Else {
- $ Height = ($ width/$ width_orig) * $ height_orig;
- }
- // Resample
- $ Image_p = imagecreatetruecolor ($ width, $ height );
- $ Image = imagecreatefromjpeg ($ filename );
- Imagecopyresampled ($ image_p, $ image, 0, 0, 0, 0, $ width, $ height, $ width_orig, $ height_orig );
- // Output
- Imagejpeg ($ image_p, $ filePath );
- ?>
$ Filename: image name, including Path
$ DstFile target path