Image Creation and Saving

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello everyone,
I have been troubleshooting a problem with one of my scripts for a
while now, its purpose is to allow a user to upload a file, save it to
the server, resize it into a thumbnail, and save the thumbnail as
well.  In my script all goes well until it comes to saving the images,
the script throws these errors:

Warning: imagepng(): Unable to open
'/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15.png'
for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on
line 91

Warning: imagepng(): Unable to open
'/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15t.png'
for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on
line 95
Picture "ffq" was added to our database! The following is what we have
generated and it is what others will see

Here is the important part of the script, if more is needed i can post
it as well.

	if ($mime_type == 'jpeg') {
	 $new_image = imagecreatefromjpeg($_FILES['new_image']['tmp_name']);
//Create an image refrence
	 }
	elseif ($mime_type == 'png') {
	 $new_image = imagecreatefrompng($_FILES['new_image']['tmp_name']);
//Create an image refrence
	 }
	elseif ($mime_type == 'gif') {
	 $new_image = imagecreatefromgif($_FILES['new_image']['tmp_name']);
//Create an image refrence
	 }

  //Image Sizes
	list($new_image_width, $new_image_height) =
getimagesize($_FILES['new_image']['tmp_name']);//Get img size
	if ($new_image_width > $new_image_height) {//Get thumb size
	 $percent_image_size = (200 / $new_image_width);
	 }
	elseif ($new_image_width < $new_image_height) {
	 $percent_image_size = (200 / $new_image_height);
	 }
	else {
	 $percent_image_size = (200 / $new_image_height);
	 }
	$new_thumb_width = ($percent_image_size * $new_image_width);
	$new_thumb_height = ($percent_image_size * $new_image_height);

	$new_thumb_file = imagecreatetruecolor($new_image_width, $new_image_height);
  imagepng($new_image,
'/home/blacknut/public_html/picserv/picserv_mysql/pictures/' .
strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . '.png');
//Copy pic to user dir as pic_id.png
	
	$new_thumb_image = imagecreatetruecolor($new_thumb_width,
$new_thumb_height); // Create Thumb file
	imagecopyresampled($new_thumb_image, $new_image, 0, 0, 0, 0,
$new_thumb_width, $new_thumb_height, $new_image_width,
$new_image_height); //Copy resized to new thumb file
	imagepng($new_thumb_image,
'/home/blacknut/public_html/picserv/picserv_mysql/pictures/' .
strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . 't.png');
//Save image thumb

I am very new to file/image manipulation in php so if you see any
errors, or unnecessary code please tell me.  I'm not quit sure how
everything works, although I do have a theoretical picture of how it
does.  Any comments will be appreciated.

--nathan

-- 
http://www.blacknute.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux