Can anyone tell me what is wrong with this code ? It used to work fine but my server has uploaded a newer version of php and it when the image resizes it loses most of its colour as though is was from 32bit to 6 colours ??
Code: Select all
<?php
#copy the original image to images/
if(!(copy($_FILES['strFile']['tmp_name'], "../images/" . $_FILES['strFile']['name'])));
session_register("nameimage1");
session_save_path();
$IMG_WIDTH = "250";
$IMG_HEIGHT = "120";
$IMG_ROOT = "../images";
$fileName = explode(".", $_FILES['strFile']['name']);
$name = str_replace(' ', '_', $fileName[0]);
error_reporting(53);
$acceptedTypes = array('image/jpeg', 'image/jpg', 'image/pjpeg');
if(!in_array($_FILES['strFile']['type'], $acceptedTypes) || trim($_FILES['strFile']['tmp_name']) == "" || trim($_FILES['strFile']['tmp_name']) =="none")
{
}
else
{
$img_orig_size = getimagesize($_FILES['strFile']['tmp_name']);
$img_orig_width = $img_orig_size[0];
$img_orig_height = $img_orig_size[1];
$img_original = ImageCreateFromJpeg($_FILES['strFile']['tmp_name']);
$image_stored = $ref. "_main.jpg";
ImageJPEG($img_original, "$IMG_ROOT/$image_stored");
$mlt_w = $IMG_WIDTH / $img_orig_width;
$mlt_h = $IMG_HEIGHT / $img_orig_height;
$mlt = $mlt_w < $mlt_h ? $mlt_w:$mlt_h;
#### Calculate new dimensions
$img_new_width = round($img_orig_width * $mlt);
$img_new_height = round($img_orig_height * $mlt);
$img_resized = ImageCreate($img_new_width, $img_new_height);
imagecopyresized($img_resized, ImageCreateFromJpeg($_FILES['strFile']['tmp_name']), 0 , 0 , 0 , 0, $img_new_width, $img_new_height, $img_orig_width, $img_orig_height);
$img_name = "$image_stored";
Imagejpeg($img_resized, "$IMG_ROOT/$img_name");
ImageDestroy($img_resized);
$mg_new_size = filesize("$IMG_ROOT/$img_name");
$newimage1 = "<img border= '1' src='$IMG_ROOT/$img_name'>";
$nameimage1 = str_replace('./', '', $image_stored);
}
?>
?>