我想将图像倾斜成梯形.左右边缘需要笔直上下; 顶部和左侧边缘需要有角度.我不知道最好的办法是什么.
我正在使用GD Library和PHP.谁能指出我正确的方向?
谢谢你,杰森
我在Amazon S3中托管了图片.我将URL static.example.com指向S3 Bucket.当我直接http://static.example.com/path/mypic.png在浏览器中输入URL 时,图像就存在,我也可以查看和下载.但是,当我想在PHP中获取图像的大小和尺寸时,它会显示此错误.
`getimagesize($path)`
Run Code Online (Sandbox Code Playgroud)
这就是错误.
A PHP Error was encountered
Severity: Warning
Message: getimagesize(http://static.example.com/path/mypic.png) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
Filename: views/template.php
Line Number: 98
Run Code Online (Sandbox Code Playgroud)
我可以在上传时将大小存储在数据库中,但这对我来说不是解决方案,我已经在S3中拥有1000x图像.当我这样做时@ getimagesize($path),错误没有显示,但没有尺寸,没有尺寸.
我还查看了PHP文档getimagesize(URL).链接示例假设支持远程图像.
检查 php.ini
Directive Local Value Master Value
allow_url_fopen On On
Run Code Online (Sandbox Code Playgroud)
哪里错了?有没有更好的方法来获取PHP中的远程图像的图像大小和尺寸?
注意我100%确定远程图像路径是否正确.
我尝试通过运行安装GD::Polygoncpan install GD::Polygon,但出现以下错误:
**UNRECOVERABLE ERROR**
Could not find gdlib-config in the search path. Please install libgd
2.0.28 or higher.
Run Code Online (Sandbox Code Playgroud)
./configure我从源代码( 、、 )手动安装了 libgd-2.2.1 ,现在当我运行时,我看到它确实已安装make:make installwhereis gdlib-config
gdlib-config: /usr/local/bin/gdlib-config
Run Code Online (Sandbox Code Playgroud)
我如何知道cpan在哪里可以找到这个库?
我的网站允许上传图片.我将图像限制为1000万像素或更少的JPEG图像,所有图像都存储在目录中.现在我想要动态调整图像大小,我正在寻找一个可以为我做的PHP类/库.虽然我可以编写(并且我已经编写)gd-library代码来调整图像大小,但我想要一些经过稳定测试的东西,更重要的是提供某种缓存.我打算像这样使用脚本:
http://www.website.name/some-script.php?image=HPIM0001.jpg&max-size=600x450
Run Code Online (Sandbox Code Playgroud)
任何建议(请提及优点/缺点).
最后,我想将JPEG图像分配给$ content_jpg变量.
$url = 'http://www.example.com/image.png';
$content_png = file_get_contents($url);
$content_jpg=;
Run Code Online (Sandbox Code Playgroud)$sourcePath = 'images/'; // Path of original image
$sourceUrl = '';
$sourceName = 'photo1.jpg'; // Name of original image
$thumbPath = 'thumbs/'; // Writeable thumb path
$thumbUrl = 'thumbs/';
$thumbName = "test_thumb.jpg"; // Tip: Name dynamically
$thumbWidth = 100; // Intended dimension of thumb
// Beyond this point is simply code.
$sourceImage = imagecreatefromjpeg("$sourcePath/$sourceName");
$sourceWidth = imagesx($sourceImage);
$sourceHeight = imagesy($sourceImage);
$targetImage = imagecreate($thumbWidth,$thumbWidth);
imagecopyresized($targetImage,$sourceImage,0,0,0,0,$thumbWidth,$thumbWidth,imagesx($sourceImage),imagesy($sourceImage));
imagejpeg($targetImage, "$thumbPath/$thumbName");
// By now, the thumbnail is copied into the $thumbpath
// as the file …Run Code Online (Sandbox Code Playgroud) 好的,我在文件中有两张图片.其中一件是T恤.另一个是徽标.我使用CSS来设置两个图像的样式,以便看起来徽标写在T恤上.我只是在CSS样式表中给徽标的图像提供了更高的z-index.无论如何我是否可以使用GD库生成衬衫和图像组合成一个图像?
谢谢,
长矛