/    Sign up×
Community /Pin to ProfileBookmark

Resizing images without GD 2.0

Hi, I am trying to copy & resize images on a server that doesn’t have GD 2.0, just GD 1.6. I encountered errors using imagecopyresampled() and imagecreatetruecolor() which I subsequently changed to imagecopyresized() and imagecreate() repectively. Now, I don’t get any errors, the image is successfully copied to the server, but the resized image, using imagecopyresized() does not get created.

Below is my code which im running. This successfully does everything when running on 2.0, so is there a way that I can successfully create the resized image using GD 1.6?

[code=php]
$filename_tmp = $_FILES[‘img’][‘tmp_name’];
$filename = $_POST[‘img_name’].$_POST[‘img_id’].”.jpg”;

$path = “./images/projects”;
$path_thumbs = “./images/projects/thumbs”;

$file_root = $path.”/”.$filename;
$file_root_thumbs = $path_thumbs.”/”.$filename;

@is_uploaded_file($filename_tmp));
@move_uploaded_file($filename_tmp, $file_root));

@chmod(“$file_root”, 0644);
$thumbs_size = 150;

$img_src = @imagecreatefromjpeg($file_root);

$Src_Sx = @imagesx($img_src);
$Src_Sy = @imagesy($img_src);

$src_w = $Src_Sx;
$src_h = $Src_Sy;

$dst_h = $thumbs_size;
$dst_w = $Src_Sx*$dst_h/$Src_Sy;

$img_dst = imagecreate($dst_w,$dst_h);

$dxy = ($Src_Sx – $Src_Sy)/2;

$srcX = 0;
$srcY = 0;
$dstX = 0;
$dstY = 0;

imagecopyresized($img_dst,$img_src,$dstX,$dstY,$srcX,$srcY,$dst_w,$dst_h,$src_w,$src_h);
@imageJPEG($img_dst,$file_root_thumbs,95);

[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinDec 11.2006 — get rid of @ and echo out the results of each call to the browser by passing the result back to a variable.

that way you can see what is really going on.

//erlin!
×

Success!

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