I AM POSTING A SECOND TIME ON THIS. I NEED SOMEONE TO HELP!!!

TO TELL ME WHERE MY MISTAKE IS: THE JPEG PHOTOS DO NOT DISPLAY CLEARLY AT ALL.... CAN YOU HELP PLEASE!!!

Thank-you Kindly, Puddin

____________________
This Is My User Form
Is The Error Here?
____________________

<?php
include 'db.php';

// initialization
$photo_upload;
$counter = 1;

if( $_GET )
$number_of_fields = (int)($_GET);


// Lets build the Photo Uploading fields
while( $counter <= $number_of_fields )
{
$photo_upload;

__HTML_END;
$counter++;
}
// Final Output
echo <<<__HTML_END

<!-Insert the photo fields here -->
$photo_upload
<html>
<head>
<title>Lets upload Photos</title>
</head>

<body>
<table class="image" cellpadding="1" cellspacing="0">
<tr>
<td>
<form name="photo_filename" action="photo1.php" method="post" enctype="multipart/form-data">
<font color=#FFFFFF><b>
Photo:
<input name="aphoto_filename[]" type="file">
Caption: <textarea name='namea' cols='20' rows='1'></textarea>
<input type='submit' name='submit' value='Add Photos'/>
<input type="HIDDEN" name="$session_name" value="$session_id"></font>
</form>
</td>
</tr>
</table>
</body>
</html>
__HTML_END;
?>

AND...
________________________________________________________
This Is The 2nd Page Process That Stores The Photo And Displays It.
Is The Error Here?
________________________________________________________

<?php
include 'db.php';

// initialization
$result_final = "";
$counter = 0;
// List of our known photo types
$known_photo_types = array(
'image/pjpeg'=>"jpg",
'image/jpeg'=>"jpg",
'image/jpg'=>"jpg",
'image/png'=>"png",
'image/x-png'=>"png",
'image/gif'=>"gif",
'image/bmp'=>"bmp"
);

// GD Function List
$gd_function_suffix = array(
'image/pjpeg' => 'JPEG',
'image/jpeg' => 'JPEG',
'image/gif' => 'GIF',
'image/bmp' => 'WBMP',
'image/x-png' => 'PNG'
);
// Fetch the photo array sent by preuploads.php
$photos_uploaded = $_FILES;


// Fetch the photo caption array
$_POST;

while( $counter <= count($photos_uploaded) )
{

if($photos_uploaded[$counter] > 0)
{
if(!array_key_exists($photos_uploaded[$counter], $known_photo_types))
{
$result_final .= "File ".($counter+1)." is not a photo<br />";

}else{

// get the variables from home page
$password = $_SESSION;
$email_address = $_SESSION;

$sql_update = mysql_query("UPDATE myd SET aphoto_filename='".($filename)."',
namea='".($namea)."' WHERE email_address='".($email_address)."' AND password='".($password)."'" );
$filetype = $photos_uploaded[$counter];
$extention = $known_photo_types[$filetype];
$filename = $namea.".".$extention;


$sql_update = mysql_query("UPDATE myd SET aphoto_filename='".($filename)."',
namea='".($namea)."' WHERE email_address='".($email_address)."' AND password='".($password)."'" );

$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){

echo ("");
} else {
echo ("");
}
// Store the orignal file
copy($photos_uploaded[$counter], $images_dir."/$name_".$filename );

// Let's get the Thumbnail size
$size = GetImageSize( $images_dir."/".$filename );
if($size[0] > $size[1])
{
$thumbnail_width = 100;
$thumbnail_height = (int)(100 * $size[1] / $size[0]);
}

else
{

$thumbnail_width = (int)(100 * $size[0] / $size[1]);
$thumbnail_height = 100;
}

// Build Thumbnail with GD 1.x.x, you can use the other described methods too
$function_suffix = $gd_function_suffix[$filetype];
$function_to_read = "ImageCreateFrom".$function_suffix;
$function_to_write = "Image".$function_suffix;

// Read the source file
$source_handle = $function_to_read ( $images_dir."/$name_".$filename );

if($source_handle)
{
// Let's create an blank image for the thumbnail
$destination_handle = ImageCreate ( $thumbnail_width, $thumbnail_height );

// Now we resize it
ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width,


$thumbnail_height, $size[0], $size[1] );
}

// Let's save the thumbnail
$function_to_write( $destination_handle, $images_dir."/$name_".$filename );


$result_final .= "<img src='".$images_dir. "/$name_".$filename."' /> <br

/>&nbsp;&nbsp; Photo ".($counter+1)." ";
}
}
$counter++;
}

echo <<<__HTML_END

<html>
<head>
<title>Photos uploaded</title>
</head>
<body>

$result_final
</font>
</body>
</html>
__HTML_END;
?>
</p>

Everything works fine, everything goes in the directory and mysql database, Gif photos display perfect, but the JPEG photos do not display clearly, Please I'm new your help to know the script code instruction will be really appreciated,

Thanks soooo Much Again, puddin!

Try changing this block of code in page 2:

if($source_handle)
{
// Let's create an blank image for the thumbnail
$destination_handle = ImageCreate ( $thumbnail_width, $thumbnail_height );

// Now we resize it
ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, 


$thumbnail_height, $size[0], $size[1] );
}

to:

if($source_handle)
{
// Let's create an blank image for the thumbnail
$destination_handle = ImageCreateTrueColor ( $thumbnail_width, $thumbnail_height );

// Now we resize it
ImageCopyResampled( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, 


$thumbnail_height, $size[0], $size[1] );
}

The difference is that first you are creating a True Color image, which will maintain the exact colours from the original image. Second, you are Resampling the image (as opposed to just resizing it). This compresses the image and maintains the pixel resolution of the image, thus no loss of quality.

Thank-you...


Your help has been appreciated, but now the Gif photos won't come up... I have tried replacing ImageCreateTrueColor with so many other image commands but i cannot get it. How does it accept both and bmp.... Thanks again, puddin

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.