Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - How to write image resource to file

Tags:

php

gd

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?

like image 257
hungneox Avatar asked Jan 11 '12 04:01

hungneox


1 Answers

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

like image 185
Annika Backstrom Avatar answered Sep 30 '22 09:09

Annika Backstrom