作者:7777-丿M | 来源:互联网 | 2023-10-11 15:27
I have an application that has to crop images with variable width & height. but i don't know how to do this with the php gd (Createimagefromjpeg) function
我有一个应用程序,必须裁剪宽度和高度可变的图像。但我不知道如何使用php gd(Createimagefromjpeg)函数执行此操作
in my code i have:
在我的代码我有:
$targ_w = 400;
$targ_h = 400;
This means that the cropped image will always get this width and height. that's not what i want. i want, in some way crop the images and crop it like i selected it at the crop area like in this picture:
这意味着裁剪后的图像将始终获得此宽度和高度。那不是我想要的。我希望,以某种方式裁剪图像并裁剪它,就像我在裁剪区域选择它一样,如下图所示:
now when i crop that image, like in the picture i get this:
现在,当我裁剪图像时,就像在图片中我得到的那样:
It is a square image because i have to give a width and height. but at every image i crop the sizes are different.
这是一个方形图像,因为我必须给出宽度和高度。但在我裁剪的每一张图片上,尺寸都不同。
Is there a way (variables, id etc..) to do this?
有没有办法(变量,id等..)这样做?
Thanks :D
EDIT: my code to create the cropped image:
编辑:我创建裁剪图像的代码:
My code to upload the image:
我上传图片的代码:
Copyright © Kees Sonnema & Jan Beetsma
My code to crop the image with JCrop:
我用JCrop裁剪图像的代码:
Selecteer een album:";
$handle = opendir($base);
while (($file = readdir($handle))!==FALSE)
{
if (is_dir($base."/".$file) && $file != "." && $file !=".." && $file !="$uploads")
{
echo "$file
";
}
}
closedir($handle);
}
else
{
if (!is_dir($base."/".$get_album) || strstr($get_album,".")!=NULL || strstr($get_album,"/")!=NULL || strstr($get_album,"\\")!=NULL)
{
echo "Dit album bestaat niet.";
}
else
{
$x = 0;
echo "$get_album";
$handle = opendir($base."/".$get_album);
while (($file = readdir($handle)) !== FALSE)
{
if ($file != "." && $file != "..")
{
echo "";
$x++;
}
if ($x==$column)
{
echo "
";
$x = 0;
}
}
}
closedir($handle);
echo "Terug Naar Albums";
}
?>
1 个解决方案