简体   繁体   English

PHP:创建图片左上方的缩略图

[英]PHP: Create thumbnail of top left of picture

I have this large png file and now I want to create a thumbnail of the upper left corner. 我有这个大的png文件,现在我想创建左上角的缩略图。

The png is like 600x1000 pixels, the thumbnail should be top left 400x300 pixels of it. png大小约为600x1000像素,缩略图应位于其左上方400x300像素。

Would be awesome if you can help me out! 如果您能帮助我,那就太好了! (Since google only shows how to thumbnail the ENTIRE picture) (由于Google只显示了如何对整个图片进行缩略图显示)

imagecopyresampled( $top_left_image_thumb,       //cropped thumbnail image
                    $original_image,             //original image
                    0, 0, 0, 0,                  //top-left corners
                    $thumb_width, $thumb_height, //dst dimensions 
                    400, 300                     //src subarea dimensions
                   );

You can use imagecopyresampled function in PHP to copy part of a source image and also scale it to any size you want. 您可以在PHP中使用imagecopyresampled函数复制部分源图像,并将其缩放为所需的任何大小。

Please check the PHP documentation for the function. 请检查PHP文档以获取该功能。

http://www.php.net/manual/en/function.imagecopyresampled.php http://www.php.net/manual/en/function.imagecopyresampled.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM