/    Sign up×
Community /Pin to ProfileBookmark

Pic resize script needs file types added…

I have a script below that resizes a jpg images. Currently only jpg files work. Can anyone tell me how to get .gif, .png, and possibly .tif and .pdf pictures to work in this script.

Thanks!

<?php
// The file
$filename = $_REQUEST[‘photo’];
$wid=625;

// Content type
header(‘Content-type: image/jpeg’);
header(‘Content-length: ‘.filesize($filename));

// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $wid;
$widthratio = $new_width / $width;
$new_height = $height * $widthratio;

// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

// Output
imagejpeg($image_p, null, 100);
?>

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@bokehFeb 17.2007 — It's amazing what a search digs up: function resize!
Copy linkTweet thisAlerts:
@NightShift58Feb 17.2007 — There you go... cheating again... Incorrigible...
Copy linkTweet thisAlerts:
@bokehFeb 17.2007 — There you go... cheating again... Incorrigible...[/QUOTE]That's part of the 95% of code I told you about! What should I have done differently?
×

Success!

Help @HDC 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.2,
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,
)...