2016-10-17 105 views
0

我正在使用http://shanechism.com/code/2011/06/facebook-picture-overlay-scriptdemo here)的修改版本来为用户上传的图片设置框架。在imagecopy上设置新图像采样为100%宽度/高度

但是,对于我的生活,我无法弄清楚如何设置框架以包含整个图像(100%宽度/高度),而不是在左下角显示为“水印”图片。

我相信答案就在下面的代码行:

imagecopyresampled($tmp, $src, 0, 0, 0, 0, $new[0], $new[1], 
    $this->uploadedInfo[0], $this->uploadedInfo[1]); 

人有什么想法?从我对Stackoverflow &的研究以外,答案并不像我希望的那么直截了当,但我想我会在这里问一下。

感谢

+0

好奇你为什么要删除http://stackoverflow.com/questions/40092268/upload-file-to-javascript-and-automatically-apply-image-overlay?你解决了问题吗? fwiw,组成了一个可能的解决方案 – guest271314

+0

我当时想要的太多了。我需要第二张图像自动应用,在第一张图像上。由于我的JS知识是有限的,所以我不确定要走的方向,所以我使用PHP来代替。我故意遗漏了下载功能,因为我不确定它是否会被允许在Stackoverflow上。 –

+0

是的,可以在stacksnippets上提供下载功能。在新'img'的'load'事件中,您没有在'canvas'上追加新图像。 – guest271314

回答

0

imagecopyresampled工作原理是这样

bool imagecopyresampled (resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h) 

你可以调整你的函数$ src_w,$ src_h,$ dst_w和$ dst_h成为源/目标所需宽度/高度

Full documentation here

相关问题