【发布时间】:2018-04-12 19:49:03
【问题描述】:
我通过基本获取图像大小并查看宽度/高度是否 = 16:9 来限制我的程序仅接受 16:9 比例的图像。
是否可以让我的程序拍摄任何图像并将其大小/重新缩放为 16:9 而不会使图像看起来很奇怪?
这是我的代码:
global $config;
$tempFile = $_FILES['file']['tmp_name'];
$mimeType = mime_content_type($tempFile);
$fileName = md5(uniqid());
switch($mimeType){
case "image/jpeg":
$filePath = "images/";
$extension = IMAGETYPE_JPEG;
break;
case "image/png":
$filePath = "images/";
$extension = IMAGETYPE_PNG;
break;
case "video/mp4":
$filePath = "videos/";
$extension = ".mp4";
break;
}
$targetFile = $config['GENERAL']['UPLOAD_PATH'].$filePath.$fileName.$extension;
move_uploaded_file($tempFile,$targetFile);
【问题讨论】:
-
is it possible to make my program take any image and resize/rescale it to 16:9是的。退房:stackoverflow.com/questions/29063094/… 该解决方案可能对您有所帮助。without making the image look weird?现在这是一个难题,是的,有可能,但我认为您需要检查原始图片的纵横比。 -
取决于您对自动裁剪图像的重视程度。如果您不介意从 4:3 到 16:9 或其他时间裁剪时人们会掉头,那么我想这是可能的,是的。
-
Resize image in PHP的可能重复
标签: php image-resizing