PHP - How to write image resource to file

孤街浪徒 提交于 2021-02-07 11:26:40

问题


I used function imagecopyresampled to cropping image.

I tried use file_put_contents and fwrite to write the resized_image to file on hard disk but all attempts were failed.

Can I write the resized image to disk instead of using imagejpg to print it out to browser?


回答1:


Here's the function signature for imagejpeg():

bool imagejpeg ( resource $image [, string $filename [, int $quality ]] )

So, provide your destination filename as the second argument. (Standard filesystem permission warnings apply, make sure the process has write access to that directory.)



来源:https://stackoverflow.com/questions/8814364/php-how-to-write-image-resource-to-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!