views:

42

answers:

1

Hi,

Im trying to create a simple image resize feature, can you tell me where i'm going wrong:

//resize image 

$imageSrc = imagecreatefromjpeg('http://www.katsmurals.com/cms/'.$target_path); $width = imagesx($imageSrc); $height = imagesy($imageSrc); echo $width; echo $height; //new dimensions $i = $width; $j = $height; while($i > 700){ $i = $i / 1.5; $j = $j / 1.5; }

$image_p = imagecreatetruecolor($i, $j); $image = imagecreatefromjpeg('http://www.katsmurals.com/cms/'.$target_path); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $i, $j, $width, $height); $newImage = $target_path.'_scaled.jpg'; imagejpeg($image_p, $newImage, 80);

$target_path is the newly uploaded image, i want to resize it if the width is over 700.

Once this is done, a DB is updated with the information, at the moment the image is being uploaded fine, but the size seems to be exactly the same, so the resizing code isn't working?

A: 

http://php.net/manual/en/function.imagecopyresampled.php

First argument of imagecopyresampled is resource (image), not string containing file name.

el.pescado
I have changed the code, still nothing, can you see where im going wrong?
@user please do some debugging. What are `width` and `height` values? What kind of image are you resizing? What format?
Pekka
.jpg file, when echo'ing out width and height these are the results:width:1235height:1551the while loop is successfully running to give new values, creating the new resized image is the problem.
I managed to get it woking, i have posted the code up for ayone who may need it in the future