我想去掉图片底部的文字。我怎样才能从底部切割它...比如说从底部切割 10 个像素。
我想在 PHP 中执行此操作。我有很多底部有文字的图片。
有办法吗?
最佳答案
给你。
要更改图像的名称,请更改 $in_filename(当前为“source.jpg”)。您也可以在其中使用 URL,尽管这显然会表现更差。
更改 $new_height 变量以设置您想要裁剪多少底部。
尝试使用 $offset_x、$offset_y、$new_width 和 $new_height,您就会找到答案。
请让我知道它有效。 :)
希望对您有所帮助!
<?php
$in_filename = 'source.jpg';
list($width, $height) = getimagesize($in_filename);
$offset_x = 0;
$offset_y = 0;
$new_height = $height - 15;
$new_width = $width;
$image = imagecreatefromjpeg($in_filename);
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopy($new_image, $image, 0, 0, $offset_x, $offset_y, $width, $height);
header('Content-Type: image/jpeg');
imagejpeg($new_image);
?>
关于php - 如何使用 PHP 从底部剪切图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2326462/