/    Sign up×
Community /Pin to ProfileBookmark

file_put_contents and resize

All,
I have the following code that works good:

[code=php]
$contents = file_get_contents( $picbigid[$i] );
$bytesWritten = file_put_contents( $saveLocation . basename($picbigid[$i]) , $contents );
[/code]

This gets the original image size of the image. Is there anyway to still use file_put_contents and just resize it to 100×100 without doing an imagecreatefromjpeg etc?

Thanks for the help in advance!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@hastxDec 04.2009 — Not to my knowledge. You will have to use a graphic utility... GD or ImageMagick to resample the pixels. I think you are risking file corruption if you simply remove bytes.
Copy linkTweet thisAlerts:
@NogDogDec 04.2009 — To actually resize the image, you'd have to do as Hastx suggests. You could, of course, output the <img> tag with height and width attributes to make it display a different size on the web page, but this obviously can waste a lot of bandwidth and time for the user if the original is much larger than the desired display size.
×

Success!

Help @treeleaf20 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...