hungneox
hungneox

Reputation: 9839

PHP - How to write image resource to file

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?

Upvotes: 15

Views: 19749

Answers (1)

user7675
user7675

Reputation:

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.)

Upvotes: 22

Related Questions