Jump to content

What am i doing wrong?


kristofferlc

Recommended Posts

I'm trying to make a thumb image and a bigger image for a gallery with a function so i can repeat the code more than once at the same page. I cant seem to make it work, and i dont know what i'm doing wrong.  :-\

I'm not very known with functions, but realy need this to work...

 

And yes i do have the GD lib instaled...

 

The code goes:

// Image function

function handleImage($imagepath, $new_width, $new_height, $img_nr, $main_nr)

  {

  $image = open_image($imagepath);

 

  // Find width and height for original image

  $width = imagesx($image);

  $height = imagesy($image);

 

  // Resample sub

  $image_resized = imagecreatetruecolor($new_width, $new_height);

  imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

 

  // Save resized image sub

  imagejpeg($image_resized, $main_nr . '/' . $img_nr . '_sub.jpg', 95);

 

  // Big width and size

  $new_height_big = "500";

  $new_width_big = $width * ($new_height_big/$height);

 

  // Resamble big

  $image_resized2 = imagecreatetruecolor($new_width_big, $new_height_big);

  imagecopyresampled($image_resized2, $image, 0, 0, 0, 0, $new_width_big, $new_height_big, $width, $height);

 

  // Save resized image sub

  imagejpeg($image_resized2, $main_nr . '/' . $img_nr . '_big.jpg', 95); 

  }

 

And this is how i call the function:

handleImage($_FILES['billede1']['tmp_name'], 100, 80, 1, $nr);

 

I've been looking trough it alot of times but still miss my error...  ??? If anyone can help me i'll be verry greatfull.

Link to comment
https://forums.phpfreaks.com/topic/85144-what-am-i-doing-wrong/
Share on other sites

In case anyone cares.

When i put out dg_info() i get this in return:

 

array(12) { ["GD Version"]=> string(27) "bundled (2.0.34 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(true) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(true) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }

Link to comment
https://forums.phpfreaks.com/topic/85144-what-am-i-doing-wrong/#findComment-434416
Share on other sites

This is odd... I seem to have found a part of the problem... I think... See, if i only try to upload (and resize) one image, it works, but as soon as i bring more than one image into the code, like here, it messes up... To me it looks like i can only handle one image at the time, witch anoys me, is there a way to solve this? (I've tryed imagedestroy() but it didnt work.)

Link to comment
https://forums.phpfreaks.com/topic/85144-what-am-i-doing-wrong/#findComment-435079
Share on other sites

The only error i've got so far is a 500 http error in the browser, witch only tells me that there sould be a programing error or that the page is under an update... I dont know if there's some other error i can make it show with a "get_error()" function or something like that, i'm not a super php programer...  :-\

Link to comment
https://forums.phpfreaks.com/topic/85144-what-am-i-doing-wrong/#findComment-435092
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.