PHP、GD、图像处理
图像缩略图等
连接到数据库以获取文件名和详细信息 该表包含所有真实的文件信息。 Mimetype、扩展名等。
物理图像位于硬盘上的文件夹路径中,并重命名如下: s:\onlinemedia\files\1\2241.dat
[类型 pjpeg] [Mime image/jpeg]
我可以获得所有这些信息,但是,当我将 header 设置为 image/jpg 时,我将字符串输出到路径。
s:\onlinemedia\files\1\2241.dat
$fileid = $passcode = '';
$fileid = (isset($_GET['fileid']) ? $_GET['fileid'] : '');
$passcode = (isset($_GET['passcode']) ? $_GET['passcode'] :'');
$filename = $frw->source->img($fileid,$passcode);
$thumb = PhpThumbFactory::create($filename);
$thumb->adaptiveResize(16,16);
$thumb->save($filename);
$thumb->show($filename);
这里到底发生了什么?
Image Thumbnails and Etc.
Connection to database for the filename and details
The table contains all the real file information. Mimetype, extensions and etc.
The physical images are located on a hdd in a folder path and are renamed as follow:
s:\onlinemedia\files\1\2241.dat
[Type pjpeg]
[Mime image/jpeg]
I can get all of that information however, when I set header to image/jpg I get the output of my string to the path.
s:\onlinemedia\files\1\2241.dat
$fileid = $passcode = '';
$fileid = (isset($_GET['fileid']) ? $_GET['fileid'] : '');
$passcode = (isset($_GET['passcode']) ? $_GET['passcode'] :'');
$filename = $frw->source->img($fileid,$passcode);
$thumb = PhpThumbFactory::create($filename);
$thumb->adaptiveResize(16,16);
$thumb->save($filename);
$thumb->show($filename);
What is really happening here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在发布的代码中看到的一件事是:
在执行
$thumb-save();
时,您需要将路径传递到新文件以将其另存为。如果您确实想这样做,那么您现在拥有的方式将覆盖原始内容。另外,$thumb->show();
不需要参数,它会偏离您用来创建对象的路径参数。我也不确定您是否需要使用 PhpThumbFactory 来弄乱标头,因为我认为 show() 方法可以处理该问题。One thing I see in the posted code is this:
When doing
$thumb-save();
you need to pass the path to a new file to save it as. How you have it now will overwrite the original if you actually want to do that. Also,$thumb->show();
shouldn't need a parameter, it goes off the path parameter you used to create the object to begin with. I'm also not sure if you need to mess with the headers using PhpThumbFactory, as the show() method handles that I think.