/    Sign up×
Community /Pin to ProfileBookmark

Get Image File and Resize?

Any idea what I would need to add to this to get an image to resize to width=990px height=1457px?

[code=php] // get current image file
$current=$pics[$pic-1];
$next=$pic+1;
if ($next > sizeof($pics)){ $next=sizeof($pics); }
$back=$pic-1;
if ($back < 1){ $back=1; }

// display image above nav
if ($navplacement!=”above”){
if (substr($current,-4) == “.jpg” || substr($current,-4) == “.gif” || substr($current,-4) == “.png” || substr($current,-4) == “.JPG” || substr($current,-4) == “.GIF” || substr($current,-4) == “.PNG”){
if ($pic < sizeof($pics)){
echo”n<p id=”cg_img”><a href=”?p=”.$next.””><img src=””.$imagedir.”/”.$current.”” alt=”Next” /></a></p>n”;
} else {
echo”n<p id=”cg_img”><img src=””.$imagedir.”/”.$current.”” alt=”End” /></p>n”;
}
}
}[/code]

Anyway to get it to run through this (resizepic)

[code=php]<?php
$photo = $_GET[‘p’];
$height = $_GET[‘h’];
$width = $_GET[‘w’];
$cmd = “/usr/local/bin/convert -size {$width}x{$height} $photo -matte -thumbnail {$width}x{$height} JPG:-“;
header(“Content-type: image/jpeg”);
passthru($cmd, $retval);
?>[/code]

Usually I just do:

[code=html]
http://www.xxx/resizepic.php?p=images/aoa4-7.jpg&w=960&h=1457
[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiSep 18.2009 — I would personally use GD. And your script has about the most serious security flaw it is possible for a script to have, ie the execution of arbitrary system commands. Anyone visiting this script could literally do ANYTHING on the server because you are not cleaning and validating your input.
Copy linkTweet thisAlerts:
@stingermanauthorSep 18.2009 — Do you mean the resize script?
Copy linkTweet thisAlerts:
@MindzaiSep 18.2009 — Yes, resizepic.php is massively unsafe.
Copy linkTweet thisAlerts:
@stingermanauthorSep 18.2009 — Thanks for the heads up.

I do use phpThumb as well, so maybe I'll just use that from now on.
×

Success!

Help @stingerman 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.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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